WordPress.org

Ready to get started?Download WordPress

Forums

No Post Today (or last 24 hours) (6 posts)

  1. hbalagh
    Member
    Posted 5 years ago #

    I was wondering if there was a plugin that would work somewhere along these lines... or if anyone knows of how to do this with some code...

    I want to have it show on the homepage if no post has been posted in the last 24 hours that says there have been no post lately but feel free to check out these post from the past (i do have a featured post plugin installed that maybe i could pull 5 random post titles from that), does this make since?

  2. Dgold
    Member
    Posted 5 years ago #

    You could run 2 loops in your home-page.

    The first loop would query all posts with Day=Today (might be able to tweak it to do 24 hour increments). If there are posts from today, then display them. If there are no posts, then display: "No Post Today, but read these posts from earlier if you like".

    The second loop would query all posts (or 5, or 20 posts) earlier-than-today, and display them.

    http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action

    Not just a plugin (that I know of), but I hope this helps if you feel like trying to accomplish this with a little bit of code.

  3. hbalagh
    Member
    Posted 5 years ago #

    anyone know of a query i could use for the first...

  4. hbalagh
    Member
    Posted 5 years ago #

    anyone?

  5. Fill in the Blank
    Member
    Posted 5 years ago #

    I do this

    <?php $recent = new WP_Query("orderby=post_date&order=desc"); while($recent->have_posts()) : $recent->the_post();?>
    <?php if ( (current_time(timestamp) - get_the_time('U') - (get_settings('gmt_offset') * 3600) ) < (3*(60*60*24))) { ?>
    <!-- content -->
    <?php } endwhile; ?>
  6. Fill in the Blank
    Member
    Posted 5 years ago #

    But I do find that it is a little finiky if you do it twice in one php page... but have at it!

    (3*(60*60*24))) is the time...
    it is in seconds (60 sec * 60 min * 24 hours) * 3 days

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.