How to Display Most View Post in the template file?

The function getPostViews() is retrieving the total number of views for each post while setPostViews() increases the post views counter each time post is viewed. You need to call setPostViews() somewhere in your single.php and then use below code to retrieve posts on basis of posts view count. $args = Array( ‘post_type’ => ‘post’, ‘posts_per_page’ … Read more

Popular Post By Month in WordPress

I’ve tested your code on my installation and it is working just fine. So the code in not an issue. There are two possible reasons why this is not showing any posts. 1) You do not have any posts for that month 🙂 2) You haven’t any metadata ‘wpb_post_views_count‘ in database so it returns nothing. … Read more

How to get a post views count using ‘WordPress popular posts’ plugin

The wpp_get_mostpopular() will give you the posts with the most views. What you want to achieve is to get the post view count by passing a post id (or using it within the loop on the single page). There is a function which accepts post id as parameter: <?php if ( function_exists(‘wpp_get_views’) ) { echo … Read more

popular post for week and month

Unless you’re storing that data, you can’t. It looks like posts_views_count is just a running total, so unless you’ve stored per month/week data, it simply does not exist. What’s more, you’re storing that data in a post meta value, which has a lot of performance and accuracy problems. It’s: incompatible with any form of page … Read more

How to display the top 5 popular links in the header?

Put this in your functions.php file function k99_post_hits( $id, $action ) { $dl_HitMetaField = ‘_dl_post_hits’; // hidden Custom field that stores the views $dl_PostHits = get_post_meta($id, $dl_HitMetaField, true); switch ($action) { case ‘count’ : if ( $dl_PostHits ==” ) { $dl_PostHits = mt_rand(10,20);//just for debug-test – remove for real count delete_post_meta( $id, $dl_HitMetaField); add_post_meta( $id, … Read more