Home › Forums › Jevelin Theme › Shortcode in Counter displays 0
Home › Forums › Jevelin Theme › Shortcode in Counter displays 0
Newbie post.
I’ve created a shortcode [user_count] which returns the number of subscribers. It works fine in a Text Block, but if I try to put it into a Counter it just returns 0. Am I missing some extra code?
Thanks
Hi @DebtCase,
I hope you are well today and thank you for your question.
It depends on how you have created that shortcode and where you are adding it to display in counter so could you please tell us more information about it so that we can help you?
Best regards,
Shufflehound team
Thanks for the response.
I create the shortcode in functions.php:
function wpb_user_count() {
$usercount = count_users();
$subscribers = $usercount[‘avail_roles’][‘subscriber’];
return $subscribers;
}
add_shortcode(‘user_count’, ‘wpb_user_count’);
Then add [user_count] into a Text Block and displays the correct number of subscribers.
If I add the same [user_count] into a Counter element (whether in a column, section or directly onto the page) it just returns 0.
In which of the counter element fields are you adding it as shown in the attached screenshot?
The number field.
Thanks
You can try achieving this by using the attached custom child theme of Jevelin theme that contains some custom code.
If you need services beyond standard support, we've got your back!
If you'd prefer not to handle the installation yourself or need help getting started, we'll set everything up for you.
We'll help you rearrange sections, adjust spacing, and modify the page structure to fit your needs.
More complex styling changes, theme option modifications, and third-party integrations.
If you need something that's not included in the theme, we can code it for you.
Web design services to create custom sections, pages, and blocks for your theme, plus graphics and visualizations.
Full website builds, custom theme development, or plugin creation from scratch.
We'll provide a clear quote based on what you need. No hidden fees.