How can i display the posts per week in a particular month?

I have to display the posts as the following

September 2010

Read More

Friday September 24, 2010

post1
post2
.
.
.

Friday September 17, 2010

post1
post2
.
.
.

Friday September 10, 2010

post1
post2
.
.
.

Friday September 03, 2010

post1
post2
.
.
.

can any one tell, how can do this?, or which function should i use?

I have used the following function and i got all the post in current month

query_posts("year=$current_year&monthnum=$current_month")

How can i show the posts per week of this month?

is it work query_posts(""year=$current_year&monthnum=$current_month&post_date >$startDate&post_date <=$endDate")

Or what is another good way?

Related posts

Leave a Reply

1 comment

  1. You’ll need to add a condition to the posts_where filter in wordpress. I have an example here for only pulling posts that are from the current post’s date and earlier:

    Add this to functions.php

    // filter wp_query when $dated_before is set
    function dg_dated_before($where)
    {
        global $wp_query, $wpdb, $dated_before;
        if (isset($dated_before)):
            $where = $where . " AND $wpdb->posts.post_date <= '". $dated_before . "' " ;
        endif;
        return $where ;
    }
    add_filter('posts_where', 'dg_dated_before') ;
    

    Use this, or similar wherever it is that you are running your query:

    global $dated_before;
    $dated_before = $post->post_date;
    $queryObject = new WP_Query();
    

    You’ll obviously need to modify this to add the date boundaries that you need.