Skip to content

Instantly share code, notes, and snippets.

@RafaelFunchal
Last active January 5, 2019 15:13
Show Gist options
  • Save RafaelFunchal/4287302 to your computer and use it in GitHub Desktop.
Save RafaelFunchal/4287302 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();
?>
@Srubens
Copy link

Srubens commented Jan 5, 2019

Se caso especifique a quantidade de posts como colocar a paginação na mesma?
Ex: coloquei na pág 10 posts e depois adiciono mais 3 posts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment