-
Notifications
You must be signed in to change notification settings - Fork 81
1. Using WPP on posts & pages
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.
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.
Plugin 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. All of the classic widget's features are available to the WPP block as well so if you have used the WordPress Popular Posts widget before you will find that the block is essentially the same thing.
For more details see WordPress Popular Posts now supports the Block Editor.
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']
If you're using the Block Editor on your website you'll want to use the Shortcode Block to insert the [wpp] shortcode (or any shortcode) into your posts & pages.
Keep in mind though that if you're planning to use custom HTML tags with the [wpp] shortcode (eg. [wpp wpp_start="<ol>" wpp_end="</ol>" post_html="<li>{thumb} {post_title}</li>"]) then the Block Editor may append some random <p></p> tags to your HTML code, breaking your custom HTML layout in the process and most likely the shortcode itself as well.
If you want to use custom HTML with your popular posts lists then use the WordPress Popular Posts block instead as it doesn't have these issues.