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.

Step 1

Install and activate Post Views Counter.

In the plugin's settings page, ensure that Post Types Count is ticked for your post type.

Step 2

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 ($37/month or $399 one-time).

Already a member? Log in below or here.

Need help implementing a tutorial in your site or want to hire me for custom work?

HIRE ME

Find the article helpful and wish to donate?

DONATE
magnifiercross
>
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: