Created
April 12, 2022 04:03
-
-
Save Musilda/3829cf7f32da82990a0da72c92cbf3c6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
add_action( 'pre_get_posts', 'apply_akce_query_filter' ); | |
function apply_akce_query_filter ( $query ) | |
{ | |
if ( is_admin() ) { | |
return $query; | |
} | |
if ( is_single() ) { | |
return $query; | |
} | |
$date = date( 'Ymd' ); | |
$meta_query = array( | |
'date_clause' => array( | |
'key' => 'datum_order', | |
'value' => $date, | |
'compare' => '>=' | |
), | |
); | |
$query->set('meta_query', $meta_query ); | |
$orderby = array( | |
'date_clause' => 'ASC' | |
); | |
$query->set( 'orderby', $orderby ); | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment