Closed ashikai closed 8 years ago
Hi @ashikai,
Is your issue the same as #71?
Hmmmm sorta? I mean, I'd be happy with that solution, but it wasn't what I was going for initially.
See, I figured out that if I add global $post to the follow link code, I can create a shortcode that I can use to display a follow button anywhere. The problem is that I can't control the follow link's placement. It will not stay contained within a div, and if I try to add my shortcode to a sidebar (for example) the follow link will display at the bottom of the page instead of in the sidebar. This is regardless of my styling choices, so I can only assume this has to do with the face that the follow link is being generated by a loop.
Current code:
function browse_follow( $atts ) { // Attributes $atts = shortcode_atts( array( 'id' => '', ), $atts, 'follow' ); global $post; 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() ) ); } endif; } add_shortcode( 'follow', 'browse_follow' );
If it can display in a menu like #71 , then that's excellent. (To clarify, getting the follow button to display inline in a menu, or even as a menu item) In the meantime I'm bumming around with my shortcode trying to figure out what the issue is.
bp_follow_add_follow_button()
is an output function.
If you want to use the follow button in a shortcode function, you need to use the return version of the function - bp_follow_get_add_follow_button()
:
https://github.com/r-a-y/buddypress-followers/blob/1.2.x/_inc/bp-follow-templatetags.php#L95
I'm going to close this as this is more of a support question and not a plugin issue, but feel free to continue replying if you have other questions.
Hello! This isn't an issue so much as a question. I know that the follow button requires a loop in order to work/display, but I was wondering if it was possible to make it show up in a menu? It's not really a loop, but it seemed possible, so I thought I'd ask.
Thanks!