Custom query to retrieve oldest post and retrieve others with date interval

I am looking to implement a custom post query that includes the following parameters:

WordPress custom loop to select the oldest post from a custom post
type and display it on the page. There are multiple pages that will
use this logic.
Use PHP/WordPress logic to retrieve the second oldest
post fourteen days later. This post would replace the oldest post on
the page.
After another fourteen days has passed, use the same logic
to the retrieve the third oldest post. This logic should continue
every fourteen days.
The same logic with a slight variation should be
used to populate an HTML dropdown menu. This menu will display all of
the posts except for the one that is currently being displayed on the
page as title, content, custom fields, etc.
Advanced Custom Fields is installed and can be used in a meta_query if necessary.


The oldest post is dated 2019-10-01. It’s post content is displayed on the page: title, content, custom fields, etc.
No other posts are displayed on the page and the HTML dropdown menu is not displayed.
After fourteen days have passed, retrieve the post dated 2019-10-15 and display it on the page.
Move the post dated 2019-10-01 into the HTML dropdown menu.
Repeat this logic every fourteen days.

Base Code

$postDate = post_date_gmt(‘Y-m-d H:i:s’);

$args = array(
‘post_type’ => ‘sendouts’,
‘cat’ => ‘101’,
‘order’ => ‘ASC’,
‘orderby’ => ‘date’,
‘date_query’ => array(
‘after’ => ‘post_date_gmt’,
‘before’ => array(
// Possibly use: $postDate->add(new DateInterval(‘P14D’)),
‘inclusive’ => true,
‘posts_per_page’ => -1,

Loop for HTML dropdown

<ul class=”sendout__list”>
<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
<a href=”<?php the_permalink(); ?>” rel=”<?php the_ID(); ?>” class=”sendout-link”>
<?php the_title(); ?>
<?php endwhile; endif; wp_reset_query(); ?>

My PHP knowledge is novice and my WordPress knowledge is midlevel, so I may be approaching this the wrong way.

Read more here:: Custom query to retrieve oldest post and retrieve others with date interval

Leave a Reply

Your email address will not be published. Required fields are marked *