Last active
January 5, 2019 15:13
-
-
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
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 | |
// 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
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