-
-
Save fabianomaximiano/0bedef4565c95654e7d3b8a2373412e5 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