Skip to content

Instantly share code, notes, and snippets.

@claudiosanches
Created February 15, 2013 21:19
Show Gist options
  • Save claudiosanches/4963621 to your computer and use it in GitHub Desktop.
Save claudiosanches/4963621 to your computer and use it in GitHub Desktop.
Exemplo de WP_Query com Custom Fields.
<?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