Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have to display the posts as the following

September 2010

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?

share|improve this question

1 Answer 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.

share|improve this answer
    
thank you very much Dan Gayle –  linto Sep 29 '10 at 16:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.