Show most popular post of last 12 months

Just as @Rarst suggested, you must have your $args defined within your function. You could solve it by using global variables, but we don’t want too many such variables flying around! Check out the PHP docs on the scope of a variable or write your code in a class. You can also simplify your query. … Read more

Sort Popular Posts by Views for the Last Week

Use strtotime to compare dates. $start = strtotime(‘yesterday’); $end = strtotime( ‘+1 week’,$start); $args = array( ‘posts_per_page’ => 5, ‘ignore_sticky_posts’ => 1, ‘meta_key’ => ‘sw_post_views_count’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘date_query’ => array( ‘after’ => $end, ‘before’ => $start, ), ); $popularpost = new WP_Query( $args ); if ( $popularpost->have_posts() ) { while ( … Read more

WordPress popular posts by week code

Currently, I see no way that you can do that as you have no good reference to pull date based statistics. Notice: You are storing post views as follows: add_post_meta($postID, $count_key, ‘0’); To be able to grab “Most viewed in period”, you would have to do something more complex, probably with an extra database table. … Read more

Popular posts by view with Jetpack

There is a Jetpack widget called Top Posts and Pages (Jetpack) If you check out the [source code][2] for this widget, you can see that it’s using the function stats_get_csv() to retrieve the stats: $post_view_posts = stats_get_csv( ‘postviews’, array( ‘days’ => 2, ‘limit’ => 10 ) ); If you want to generate your custom most … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)