03-16-2015, 10:13 PM
After an extenisive search I finally found the following code that lets me display my WP posts on a on a WP page. This is great, but what I really need is to be able to display just the posts created in the last 24 hours. Does anyone know what changes I need to make to limit the results to the last 24 hours or so?
Thank you in advance
Code:
<?php
/*
Template Name: All posts
*/
?>
<?php
$debut = 0; //The first article to be displayed
?>
<?php while(have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<ul>
<?php
$myposts = get_posts('numberposts=-1&offset=$debut');
foreach($myposts as $post) :
?>
<li><?php the_time('d/m/y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
<?php endwhile; ?>
Thank you in advance