How to display popular posts sorty by day, week, monthly, all (1 post)

Discussion in 'WordPress' started by ibadullah, Feb 24, 2014.

  1. #1
    Hi everyone,

    I'm trying to display popular posts sort by Day, Week, Month and All using this SNIPPET

    This is the query I'm using to display the popular posts.

    For Monthly
    <ul>
        <?php
        $month = date('m');
        $year = date('Y');
        query_posts('meta_key=post_views_count&orderby=meta_value_num&order=DESC&year=' . $year . '&monthnum=' . $month);
        while (have_posts()): the_post(); ?>
    
    <li><a>" title="<?php printf(esc_attr('Permalink to %s'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></li>
        <?php
        endwhile;
        wp_reset_query();
        ?>
    
    </ul>
    PHP:
    This will display All Time Popular Posts
    <ul>
    
        <?
        query_posts('meta_key=post_views_count&orderby=meta_value_num&order=DESC');
    
        while (have_posts()): the_post(); ?>
    
        <li><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr('Permalink to %s'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></li>
    
        <?php
        endwhile;
        wp_reset_query();
        ?>
    
        </ul>
    PHP:
    Both the above codes are working but I don't know how to display popular posts for Day and weekly?
     
    ibadullah, Feb 24, 2014 IP
  2. saikatkhulna

    saikatkhulna Member

    Messages:
    15
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    33
    #2
    Hello

    i think this link http://www.wpbeginner.com/wp-tutorials/display-popular-posts-by-day-week-month-and-all-time-in-wordpress/ will help you.
    Here is an clear description to Display Popular Posts by Day, Week, Month, and All Time in WordPress.
     
    saikatkhulna, Feb 25, 2014 IP
  3. ibadullah

    ibadullah Active Member

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    63
    #3
    Thank you but that link doesn't help me a lot because I'm trying to add this function manually and the guide you show me is about the plugin.


    I just need a query to call using this function.
     
    ibadullah, Feb 25, 2014 IP