• I have a Snippet for Posts for today by categorie.

    Can i Change this to the last 7 Days? (seperate by day not category)

    <?php
    $today = getdate();
    $categories = get_categories(array('hide_empty' => 1, 'orderby' => 'id', 'selected' => $category->parent, 'hierarchical' => true, 'show_option_none' => __('None')));
    foreach ($categories as $category) {
        query_posts('year='.$today["year"].'&monthnum='.$today["mon"].'&day='.$today["mday"].'&post_type=post&post_status=publish&cat='.$category->term_id);
        echo "  <li>\n"
            ."    <span class=\"tag-headline\" href=\"".get_category_link($category->term_id)."\">".$category->name."</span>\n<p class=\"tag-headline-border\"></p>"
            ."    <ul>\n";
        while (have_posts()) : the_post();
    ?>
    
    posts
    
    <?php
        endwhile;
        echo "    </ul>\n"
            ."  </li>\n";
    }
    ?>
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Hello again!

    You can, but it’s not so simple. It is simple to get posts for a particular week number, but not for an arbitrary date range. Date ranges require the use of the ‘posts_where’ filter to modify the current raw mySQL query. See Class_Reference/WP_Query#Time_Parameters for examples which you can adapt.

Viewing 1 replies (of 1 total)
  • The topic ‘Last 7-Days-News’ is closed to new replies.