Created
February 15, 2013 21:19
-
-
Save claudiosanches/4963621 to your computer and use it in GitHub Desktop.
Exemplo de WP_Query com Custom Fields.
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 | |
/** | |
* Exemplo de WP_Query para custom fields. | |
*/ | |
$custom_query = new WP_Query( array( | |
'meta_key' => 'custom_field', // Nome do custom field. | |
'meta_value' => true, // Valor do custom field. | |
'posts_per_page' => 10, // Quantidade de posts. | |
'post_status' => 'publish', // Pega apenas os posts publicados | |
'ignore_sticky_posts' => 1 // Não adiciona os Sticky Post | |
) ); | |
// Loop | |
while ( $custom_query->have_posts() ) : | |
$custom_query->the_post(); ?> | |
<!-- Sua mágica aqui :P --> | |
<?php | |
endwhile; | |
wp_reset_postdata(); // Reseta as informações da Query personalizada. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment