Skip to content

1. Using WPP on posts & pages

Héctor Cabrera edited this page Oct 19, 2021 · 13 revisions

WordPress Popular Posts (WPP from now on) can be inserted into your posts and/or pages either via the [wpp] shortcode or, if you're using the Block editor (a.k.a. Gutenberg) there's also a WPP block that you can insert into your content.

The WordPress Popular Posts block

To quote the official documentation, "Blocks are the components for adding content in the new WordPress block editor." If you're still not familiar with the new editor you can learn more about it here: WordPress Block Editor.

Version 5.4.0 introduced the WordPress Popular Posts block for everyone (it was available before but only as an experimental feature).

The WPP block works almost just like the classic WordPress Popular Posts widget. Most of the classic's features are available to the WPP block as well so if you have used the WPP widget before you'll find that the block is essentially the same thing.

For more details see WordPress Popular Posts now supports the Block Editor.

The [wpp] shortcode

Shortcodes are macro codes that allow users (that's you!) to insert bits of predefined functionalities into post/page content.

WordPress Popular Posts takes advantage of this feature so you can insert a list of popular posts on, for example, a Hall-of-Fame page or in the middle of a blog post so your readers can see what's popular / trending on your website at the moment.

Without any parameters the [wpp] shortcode will list the most viewed posts (up to 10) within the last 24 hours. To customize the shortcode (eg. change the number of posts, hide/show views count, etc.) have a look at the full list of parameters.

For example, this shortcode would display the top 5 viewed posts from the last 7 days:

[wpp range='last7days' limit=5 stats_views=1 order_by='views']

And this one would output the 10 most commented posts from the last 30 days:

[wpp range='last30days' stats_comments=1 order_by='comments']

The [wpp] shortcode and the Block Editor (a.k.a. Gutenberg)

If you're using the Block Editor on your website please make sure to use the Shortcode Block when inserting the [wpp] shortcode into your posts & pages, especially if you're using HTML-related parameters with it (like post_html). Otherwise your popular posts list may not work as expected (if at all).