Last active
August 29, 2015 14:01
-
-
Save bi0xid/93b35d2cbebceb06a2a4 to your computer and use it in GitHub Desktop.
WP_Query with meta query
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 | |
// Ejemplo complejo. Post Type 'historia', con un campo 'fecha_de_entrega' numérico (YYYYMMDD), y otro campo 'pila'. | |
$args = array( | |
'post_type' => 'historia', | |
'meta_key' => 'fecha_de_entrega', | |
'orderby' => 'meta_value_num', | |
'nopaging' => 'true', | |
'order' => 'ASC', | |
'meta_query' => array( | |
array( | |
'key' => 'pila', | |
'value' => 'sprint', | |
'compare' => 'IN', | |
) | |
) | |
); | |
$query = new WP_Query( $args ); | |
// Ejemplo normal. Páginas ordenadas por menu_order y, en caso de tener el mismo, por título. Orden descendente. | |
$query = new WP_Query( array ( 'orderby' => 'menu_order title', 'order' => 'DESC' ) ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment