Skip to content

Instantly share code, notes, and snippets.

@victorknust
Forked from RafaelFunchal/WP_Query()
Created February 2, 2016 11:44
Show Gist options
  • Save victorknust/9e9f5d95784d3e7b1308 to your computer and use it in GitHub Desktop.
Save victorknust/9e9f5d95784d3e7b1308 to your computer and use it in GitHub Desktop.
Como exibir apens posts de uma determinada categoria na sua página WordPress
<?php
// Documentação completa em http://codex.wordpress.org/Class_Reference/WP_Query
$args = array(
'cat' => 1, //ID da sua categoria
'posts_per_page ' => 4, // Número de posts a exibir
);
$novo_loop = new WP_Query( $args );
if ( $novo_loop->have_posts() ) : while ( $novo_loop->have_posts() ) : $novo_loop->the_post();
?>
INSIRA AQUI O CONTEÚDO DO SEU LOOP
<?php
endwhile;
else :
?>
CASO NÃO EXISTA POSTS
<?php
endif;
// Reseta as queries
wp_reset_postdata();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment