I have a query that is used to display search results from search. The query is in search.php. It shows custom posts and pages in the search result, which is what I want. I have a custom post type called 'event', each post has a date stored in
_event_start_date. I want to compare
_event_start_date (a meta key) with the current date and exclude event posts that are in the past from the search result.
My working query:
if ( have_posts() ) : ?> <h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'shape' ), '<span>' . get_search_query() . '</span>' ); ?></h1> <?php while ( have_posts() ) : the_post(); ?> <a href="<?php echo get_permalink( ); ?>"><?php echo the_title(); ?></a> <?php endwhile; ?> <?php else : ?> <p> there were no results </p> <?php endif; ?>
How can I include
_event_start_date in the above code, so that if an event has already started it is not shown in the search result? The date is formatted as