Query Posts every X amount of hours
-
If this has already been answered, I apologize … I wasn’t able to find it on my own.
I’m not very good with PHP so I’m completely stuck and looking for help.
I have a query call for custom post types that pull in both the custom fields, and custom post information. There’s 4 posts (out of 14) that are being called at random. I was able to get this functioning exactly as I wanted it to. The issue I’m having now is I need to alter the query so that it only changes the display every 24 hours instead of everytime the page loads.
So basically… if Sunday – display 4 posts…. if 24 hours later display another 4 posts.
These posts need to be completely randomized… my code is below.
How do I add the ‘change every 24 hour’ factor to it?
<ul> <?php query_posts("post_type=chapter&orderby=rand&posts_per_page=4");?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <li> <div class="authors"> <a href="<?php the_permalink();?>"><img src="<?php $post_object = get_field('article_author'); if( $post_object ): // override $post $post = $post_object; setup_postdata( $post ); the_field("profile_image"); $first=get_field("first_name"); $last=get_field("last_name"); endif; wp_reset_postdata(); ?>"></a> <div class="author-name-home"><?php the_title();?></div> <div class="author-title-home"><?php echo $first;?> <?php echo $last;?></div> </div> </li> <?php endwhile; endif; wp_reset_query(); ?> </ul>
Thank you in advance
- The topic ‘Query Posts every X amount of hours’ is closed to new replies.