Most Read Articles in WordPress Show (without plugin)

Today in this article I will show how you can know about the most read article based on the page impressions (views) of your blog that can be easily displayed without the use of plugins.

So let us begin and I will now show you below the way of knowing the most popular article item list for your blog.

The code for determining the most read articles

Can you add the following code in your functions.php of your theme adds:

You have to do the most important thing here is use the get_posts function to get to know the items with the most page views (Views) to fetch from the database. The product thus obtained is then displayed in a linked list.

Brief Description of the code

Line 5 & 24:

We store the previous and current data of the existing article in a variable (line 5) to this later global $ post assign variable (line 24). This is only for security, if in your theme, after calling the get_popular_posts_by_views function, the data are still needed to the current article - to post $ will be accessed again.

Line 7 - 14:

Get the most read articles from the database. The article according to page views (Views) are sorted in descending order, so that the article with most page views (Views) can be output first.

Line 16-22:

Composition of the issue of the article with the most page views (views).

The code to display the most read articles

The following code can be placed anywhere in your WordPress theme. So if you want eg the list of the top 3 show the most widely read and therefore most appreciated products in the sidebar of your blog, you can add the following code example in the sidebar.php insert:

  1. echo  get_popular_posts_by_views (3);


With the variant presented in this article show the most viewed articles, you have now identified a further possibility, as you can list the most popular items of your blog easily.

Leave a reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.