In the WPDevDesign Facebook group a user wrote:
Hi all, What's the best way to list the 5 most popular articles in the same taxonomy as the current article (excluding current article). Can this be done with a repeater?
This premium tutorial provides the code for a custom WP_Query that pulls 5 recent entries of a particular post type that have the same taxonomy terms (checks for each term separately) as the current entry sorted by the number of views while excluding the current entry on single entry pages of a CPT.
We shall use Post Views Counter plugin for tracking the number of views for the CPT entries.
Install and activate Post Views Counter.
In the plugin's settings page, ensure that Post Types Count is ticked for your post type.
In the Template that applies to single entries of your desired post type, add the following PHP code.
If using Oxygen, add it inside a Code Block.
This is a premium members-only content.
To view the rest of the content, please sign up for membership ($47/month or $499 one-time).
Already a member? Log in below or here.