Last active
November 26, 2015 17:41
-
-
Save igmoweb/218d81f3d305646a55f2 to your computer and use it in GitHub Desktop.
meta query
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
add_action( 'pre_get_posts', 'order_conciertos_by_date' ); | |
function order_conciertos_by_date( $query ) { | |
if ( is_admin() ) | |
return; | |
if ( $query->get( 'post_type' ) != 'concierto' ) | |
return; | |
$today = current_time( 'timestamp' ); | |
$today = date( 'Ymd', $today ); | |
$meta_query = array( | |
array( | |
'key' => 'show_fecha', | |
'compare' => '>=', | |
'value' => $today, | |
'type' => 'numeric', | |
) | |
); | |
$query->set( 'meta_query', $meta_query ); | |
$query->set( 'meta_key', 'show_fecha' ); | |
$query->set( 'orderby', 'meta_value_num' ); | |
$query->set( 'order', 'DESC' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment