Support

Account

Home Forums General Issues WP Query, filter by date

Unread

WP Query, filter by date

  • I’m trying to only display job postings if the closing date if after or equal today.

    Below is how I’m attempting to solve this, its not behaving correctly.

    <?php

    $today = date(‘Ymd’);

    $job_args = array(
    ‘posts_per_page’ => -1,
    ‘post_type’ => ‘job_posting’,
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘closing_date’,
    ‘compare’ => ‘>=’,
    ‘value’ => $today
    )
    ),
    );

    $job_query = new WP_Query( $job_args );
    ?>

    <?php if( $job_query->have_posts() ): ?>
    <?php while ( have_posts() ) : the_post(); ?>

  • ” target=”_blank”><?php the_title(); ?>
    <span class=”date”>Closing date: <?php the_field(‘closing_date’); ?></span>
    <span class=”notes” style=”color:black !important;font-weight:normal !important”>
    <?php the_field(‘notes’); ?>
    </span>
  • <?php endwhile; ?>
    <?php else: ?>
    No job postings currently available.

    <?php endif; ?>

Viewing 1 post (of 1 total)

The topic ‘WP Query, filter by date’ is closed to new replies.