Skip to content

Instantly share code, notes, and snippets.

@Musilda
Created April 12, 2022 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Musilda/3829cf7f32da82990a0da72c92cbf3c6 to your computer and use it in GitHub Desktop.
Save Musilda/3829cf7f32da82990a0da72c92cbf3c6 to your computer and use it in GitHub Desktop.
<?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