Skip to content

1. Using WPP on posts & pages

Héctor Cabrera edited this page Jul 29, 2021 · 31 revisions

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).

Clone this wiki locally