Repost post on specific date every year

Rather than re-post the posts, we can create a custom query for the current day’s post regardless of year. We use current_time to get the current day and month according to the site’s timezone settings, then we create a new query containing date parameters for month and day. We don’t specify a year, so it’ll return anything posted on this day from any year.

$day = current_time( 'j' );
$month = current_time( 'n' );

$args = array(
    'date_query' => array(
        array(
            'month' => $month,
            'day'   => $day,
        ),
    ),
);
$today = new WP_Query( $args );

if ( $today->have_posts() ) {
    while ( $today->have_posts() ) {
        $today->the_post();
        // output the post
        the_title();
    }
    wp_reset_postdata();
}

Leave a Comment