Home Forums Front-end Issues Filtering posts with by date (Date Picker)


Filtering posts with by date (Date Picker)

  • Hi everyone,

    I was wondering if it is possible to filter posts by date (which is set in a date picker)?
    Right now I have this, which works but isn’t the most elegant solution:

    $wpb_all_query = new WP_Query(array(
    <?php if ( $wpb_all_query->have_posts() ) : ?>
     <?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?>
    <?php $post_id = get_the_ID();?>
    <?php if ( $wpb_all_query->have_posts() ) : ?>
    //if get_field("workshop_startdate", $post_id) is before today
    /* display post */
    <?php endwhile; ?>
    <?php endif; ?>

    Is there a way of having the filtering done in the query?

  • G’day mate,

    If you already have acf date field setup, you can include the date as part of your wp query.

    See the last example “Query posts based on date” in the Date Picket documentation.

    Cheers, 😇

  • coolness,

    meta query to the rescue 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.