Last active
January 9, 2019 22:34
-
-
Save kingkool68/7f3286c19167351d0a6618422a284d77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function action_pre_get_posts( $query ) { | |
if ( $query->is_tax() && $query->is_main_query() ) { | |
$meta_query = array( | |
array( | |
'key' => 'date', | |
'compare' => '>=', | |
'value' => date( 'Ymd' ), | |
), | |
array( | |
'key' => 'start_date', | |
'compare' => '<=', | |
'value' => date( 'Ymd', strtotime( '2019-06-01' ) ), | |
), | |
array( | |
'key' => 'end_date', | |
'compare' => '>=', | |
'value' => date( 'Ymd', strtotime( '2019-06-30' ) ), | |
) | |
); | |
$query->set( 'meta_query', $meta_query ); | |
} | |
} | |
add_action( 'pre_get_posts', 'action_pre_get_posts' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function action_pre_get_posts( $query ) { | |
if ( $query->is_tax() && $query->is_main_query() ) { | |
$meta_query = array( | |
array( | |
'key' => 'date', | |
'compare' => '>=', | |
'value' => date( 'Ymd' ), | |
), | |
); | |
$query->set( 'meta_query', $meta_query ); | |
} | |
} | |
add_action( 'pre_get_posts', 'action_pre_get_posts' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment