Using the WordPress Default 1.6 theme index.php file:
Changed this code from:
<?php while (have_posts()) : the_post(); ?>
to:
<?php while (have_posts()) : the_post(); ?>
<?php
$mylimit=30*(60*60*24);
if ( (current_time(timestamp) - get_the_time('U') - (get_settings('gmt_offset') * 3600) ) < $mylimit)
{
?>
and this code from:
</div>
<?php endwhile; ?>
to:
</div>
<?php } ?>
<?php endwhile; ?>
Entire index.php posted at http://wordpress.pastebin.ca/746974
Example to change the number of days from 30 to 45
$mylimit=45*(60*60*24);
Thread Starter
slunk3
(@slunk3)
Great! This works, but is there a way to still access older posts from the index page?
using
<?php posts_nav_link(' — ', __('« Previous Page'), __('Next Page »')); ?>
This works brilliantly.
I’m using it to display the posts from the past 24 hours.
If there weren’t any posts in the past 24 hours it obviously displays nothing.
So my question is, is there a way to use that code and add to it so if no posts are available, it displays the previous day’s?
Maybe you could add to:
$mylimit=1*(60*60*24);
with:
elseif $mylimit=2*(60*60*24);
?