Need part of code to only display last 7 days of posts
-
I am about 98% completed on getting code for my functions.php in WordPress that will generate a list of all the posts on my blog from the last 7 days. However the part where I create code to generate “the last 7 days” of posts is creating problems.
Here is the code so far, but it lacks all the nonsense I had before that didn’t work to grab only the last 7 days of posts. Can anyone see where I should add the information about “the last 7 days” and how that should be placed?
function show_post_by_category_and_by_last_week($args = '') { global $post; $categories = get_categories($args); echo "<ul>"; $i = 0; foreach ($categories as $category) : $i++; ?> <li> <h2><a href="<?php echo get_category_link($category->term_id);?>"><?php echo $category->name; ?></a></h2> <ul> <?php $posts = get_posts('category='. $category->term_id); foreach($posts as $post) : ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul> <div class="read-more"><a href="<?php echo get_category_link($category->term_id);?>">MORE »»</a></div> </li> <?php if ($i % 3 == 0) { echo "</ul><ul>"; } endforeach; echo "</ul>"; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Need part of code to only display last 7 days of posts’ is closed to new replies.