Hi @itism64,
The [wpp] shortcode returns a list of all popular posts so that won’t work.
Since WordPress Popular Posts doesn’t have a shortcode to display the views count of a post or a page you could just simply create a new shortcode, like this for example:
/**
* Registers the shortcode [wpp_views_count].
*
* @author Hector Cabrera (https://cabrerahector.com)
* @return string
*/
function wpp_views_count_func() {
if (
function_exists('wpp_get_views')
&& is_single()
) {
$views_count = wpp_get_views( get_the_ID() );
return ($views_count == 1) ? '1 view' : $views_count . ' views';
}
return '';
}
add_shortcode( 'wpp_views_count', 'wpp_views_count_func' );
Add that to your theme’s functions.php file and then you can use [wpp_views_count] on your posts and pages.
Hi Hector,
Thanks for the quick reply.
If i place the code i get a error
Your PHP code changes were rolled back due to an error on line 148 of file wp-content/themes/astra/functions.php. Please fix and try saving again.
syntax error, unexpected ‘&’
Did i do something wrong here?
Cheers
Works for me with the Twenty Seventeen theme so I’m not sure what’s going on. Make sure you’re pasting that code snippet at the end of your theme’s functions.php file to avoid messing around with the existing code.

Hola Hector,
Changed to Twenty Seventeen and same “error” result
Your PHP code changes were rolled back due to an error on line 623 of file wp-content/themes/twentyseventeen/functions.php. Please fix and try saving again.
syntax error, unexpected ‘&
Cheers
Oeps,
Seen what i do wrong. The copy /past made small mistake. Works perfect sorry about that.
No idea, man. As the image from above clearly shows, copying&pasting that code into WordPress’ built-in theme editor works just fine for me.
Try changing:
if (
function_exists('wpp_get_views')
&& is_single()
)
into:
if ( function_exists('wpp_get_views') && is_single() )
and see if it fixes the issue.
Edit: saw your last comment just now. Glad to know you were able to work it out!
i’am using different theme as like orao . is it work the on it?
also is this code work for grid plugins?
Hey @furkanbaser,
Yes, this will work on any theme.
@hcabrera This could definitely be integrated within the plugin natively 🙂
But the “views” suffix as to be stripped so we can put any words we need, or no words at all. 🙂
-
This reply was modified 6 years, 10 months ago by
X-Raym.
-
This reply was modified 6 years, 10 months ago by
X-Raym.