WordPress.org

Ready to get started?Download WordPress

Forums

popular posts this month not all time! (2 posts)

  1. adamshriki
    Member
    Posted 12 months ago #

    Hi!
    We have this site:
    hafla
    on the left side is the popular posts by this code:

    $side_posts = new WP_query();
                                        $side_posts->query(array('category__in'=>array(16), 'posts_per_page'=>3, 'post_type'=>'post','meta_key'=>'_hafla_pageview','meta_value'=>0, 'meta_compare'=>'>', 'orderby'=>'meta_value_num', 'order'=>'DESC'));
                                        while($side_posts->have_posts()){
                                        $side_posts->the_post();

    but it's the popular posts by all times, and I want popular posts this month.

    how can i achieve this?

    thanks in advance,

    Adam Shriki.

  2. bcworkz
    Member
    Posted 11 months ago #

    Take at look at Query time Parameters and the examples provided. Getting posts in the current calendar month is straight forward. Use $today = getdate(); then add 'monthnum' => $today["mon"], to your query array. Getting posts from the last 30 days is more complicated, but achievable.

Reply

You must log in to post.

About this Topic