Tagged: good theme
Hello Brajesh,
I’ve added the add as follow button inside my post (content-single.php) and it works, but its not using ajax like on the members directory. When I click on “Follow-Unfollow” it reloads the entire page, how can I make it follow without reloading the entire page?
I found this links but I don’t undertand the conversations.
https://wordpress.org/support/topic/display-followunfollow-button-anywhere/https://wordpress.org/support/topic/ajax-doesnt-respect-link-class-param/?replies=3#post-6018349
https://github.com/r-a-y/buddypress-followers/wiki/Add-a-follow-button-on-a-regular-WP-page
This is the code I added to my (content-single.php) file but it’s not loading with ajax
<?php if ( function_exists( 'bp_follow_add_follow_button' ) ) : if ( bp_loggedin_user_id() && bp_loggedin_user_id() != get_the_author_meta( 'ID' ) ) { bp_follow_add_follow_button( array( 'leader_id' => get_the_author_meta( 'ID' ), 'follower_id' => bp_loggedin_user_id(), 'link_class' => 'post-follow-btn' ) ); } endif; ?>
Thank you
I will test and share some code by Monday.
It should b easy.
Hi Tosin,
I am sorry I haven’t been able to find time to use the Follower plugin. Will do today and get back to you.Thank you
BrajeshHi Tosin,
Whihc theme are you using? We will need to add following code in the js filejQuery( document).ready( function ($) { $(document).on("click", ".hentry .follow-button a", function() { bp_follow_button_action( $(this) ); return false; }); });
Adding that will make the button work via ajax.
Regards
BrajeshHello Brajesh,
THANK YOU, THANK YOU VERY MUCH The code worked perfectly I added it to the bp-follow.js file. I was wondering if its possible to add the code to child-theme.
I am using the klein theme at https://themeforest.net/item/klein-a-nittygritty-community-theme/5418518
God bless
Hi Tosin,
I am sorry, I don’t use that theme. If they have provide a way to add custom js, it will be fine. Or you can create a custom js file and add some code in functions.php to load the file.Regards
Brajesh
The topic ‘How to make custom follow button load with ajax’ is closed to new replies.