Determine if Post is between date range, and set Season #

I have a Post type called Entries, and a custom Taxonomy called Season. Season has meta Beginning Date and End Date.

I’m working on a function that automatically sets the Season number based on the post submission date, and getting hung up on the final conditional statement.
What am I missing here?

function determine_season( $post_id ) {
// Get submission date.
if ( is_singular( ‘entries’ ) ) {

$submission_date = get_the_date();

// Loop through seasons.
/* Get the genres for the post. */
$terms = get_the_terms( $post_id, ‘seasons’ );

foreach ( $terms as $term ) {
$beginning_date = get_field( ‘beginning_date’, $term );
$end_date = get_field( ‘end_date’, $term );

// If submission date is LESS than end date && GREATER than beginning date, then set Posts Season to corresponding Season.
if ( $submission_date >= $beginning_date && $submission_date <= $end_date ) {

wp_set_post_terms( $post_id, $term->id, ‘seasons’, false );

}
}
}

}
add_action( ‘save_post’, ‘determine_season’ );

Read more here:: Determine if Post is between date range, and set Season #

Leave a Reply

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