• At my workplace we are converting from WP v2.0.x to v2.6. One feature from v2.0 that they want brought over to the new version is the ability to show all posts from the last 5 days. Because for some days no posts were published (such as over the weekends), I should qualify this with ‘show all posts from the last 5 days that contained posts‘. This feature originally existed in v2.0.x in the admin, under the Reading Options/Settings, which would allow the user to select either ‘Posts’ or ‘Days’ for the Show at Most setting.

    So far, I have been unable to replicate this feature. I had a look at the v2.0 code, and quickly decided that editing the core files for this is above and beyond my skill. Since we only need this feature for the index page, I was hoping for a quick hack to implement this. One implementation I have been playing around with (pseudocode):

    $posts_per_page = 5;
    query_posts()
    
    while (have_posts(): the_post())
    {
      if (the_time('m.d.Y') for this post == the_time('m.d.Y') for last post)
      {
        $posts_per_page++;
      }
    }
    
    rewind_posts()
    
    query_posts('posts_per_page='.$posts_per_page)
    ...(Show posts, etc.)

    This implementation is not working for me, but perhaps something like this will work? Any thoughts?

Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Show all posts for last 5 days that contained posts’ is closed to new replies.