• Resolved gnurf

    (@gnurf)


    I hope someone can help me in the right direction with this one:

    Say you have some contributors writing posts about weekly happenings. One write about Monday happenings and another about Tuesday happenings and so on. These post are written a week or so in advance.

    How can I list all posts for a preferred week, for example current week and next week?

    All suggestions are welcome!

    -Paul

Viewing 4 replies - 1 through 4 (of 4 total)
  • http://codex.wordpress.org/Class_Reference/WP_Query
    http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters

    example:

    $this_week_query = new WP_Query(array('posts_per_page' => -1, 'w' => date('W')));

    $next_week_query = new WP_Query( array('posts_per_page' => -1, 'w' => (date('W')+1)) );

    (not tested)

    if it is the only query on the page, you could also try to work with query_posts() using the same parameters;
    http://codex.wordpress.org/Function_Reference/query_posts

    Thread Starter gnurf

    (@gnurf)

    Should the post be published as scheduled for upcoming weeks, or is there any other ways of adding a “time stamp” if you publish immediately?

    If you schedule a post for an upcoming date, it won’t be visible on the site until that date is reached. So if your intention is to have a list of articles about upcoming events that people can read ahead of time, you’ll need to publish them immediately.

    If you need to add an additional timestamp, I’d just put it in a custom field and add that field to your template. Or alternatively just use Taxonomy and categorize the posts by day of the week.

    Thread Starter gnurf

    (@gnurf)

    Excellent! Got it working. By adding post_status set to publish and future I am also able to list scheduled posts:

    $my_query = new WP_Query(array(‘post_status’ => ‘publish,future’, ‘posts_per_page’ => -1, ‘w’ => date(‘W’),’order’=>ASC));

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘how to show post of current week’ is closed to new replies.