[Resolved] Shortcode to show number of members
-
Hi!
I’m learning how to create shortcodes and am trying to create a shortcode to show the current number of members in my network. This is the code I’m using:
`function show_number_of_members() {
$count=bp_total_member_count();
return $count;
}function register_shortcodes() {
add_shortcode(‘member_count’, ‘show_number_of_members’);
}add_action( ‘init’, ‘register_shortcodes’);`
Now, the code works when using the shortcode [member_count] but the number is displayed at the top of the page. This happens when you use “echo” in PHP because that gets parsed before the page content, but nothing changed after I switched to the “return” command. The code is placed in a “functions-custom.php” file where I keep my custom functions. I’m sure this is a simple mistake, can anyone here help me correct it? Thanks!
- The topic ‘[Resolved] Shortcode to show number of members’ is closed to new replies.