Library Technology - Reviews, Tips, Giveaways, Freeware

Library Technology – Reviews, Tips, Giveaways, Freeware

WordPress Tips: Display most viewed posts first on search pages

Posted In Wordpress tips - By Techtiplib on Wednesday, October 3rd, 2012 With No Comments »

WordPress by default, shows latest posts first on archive and search pages. Here I will show you how tosort your posts on search results page using post view counts.

Step 1. Install Lester Chan’s post views plugin. 
This plugin counts every time a visitor views a single post page. Go to Plugins > Add New > Search and type wp postviews for easy install.

Step 2. Open functions.php and add the code below to the end of the file right before ?> (if there is one).

tech tips, wordpress tips

This code filters your posts when a visitor views your search page. It sorts results by post view counts. Your most visited posts will be on top.

Step 3. Save & upload the file to your server.

If you just installed the wp-postviews plugin, it may take some time for this trick to work.


More contents in:

About - Hey, this blog belongs to me! I am the founder of TechTipLib and managing editor right now. And I love to hear what do you think about this article, leave comment below! Thank you so much...