Support » Plugin: Top 10 - Popular posts plugin for WordPress » Why most viewed post in a week not working

  • I have this codes `<?php
    //Set the parameters / arguments for the query
    $popular_post_args = array(

    ‘meta_key’ => ‘post_views_count’, //meta key currently set
    ‘orderby’ => ‘meta_value_num’, //orderby currently set
    ‘order’ => ‘DESC’, //order currently set
    ‘posts_per_page’ => 10, // show 10 posts
    ‘date_query’ => array( // date query from after 1 week ago
    ‘after’ => ‘1 week ago’,

    //Initialise the Query and add the arguments
    $popular_posts = new WP_Query( $popular_post_args );

    //Check if theres posts and add your html divs around it
    if ( $popular_posts->have_posts() ) : ?>

    //Start the loop
    while ( $popular_posts->have_posts() ) : $popular_posts->the_post(); ?>`
    Which I used to display most viewed post in a week but it fails to achieve what I am looking for. It outputs post in a week but is not able to show 10 post as set. sometimes it shows no post at all meaning there is no popular post in a week. Please is there a way I can modify this code to show most viewed post in a week updating it as newer or older post that falls withing one week gets viewed. For instance if I make a new post and share on Facebook it definitely attracts more views but this code able doesnt update it. So I want something that can update this list of 10 post whenever the views changes. Thanks for your help in advance.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Ajay


    This plugin doesn’t use a meta key – are you using another plugin and not Top 10 for this?

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.