Aprenda como como listar todos os posts de seu wordpress geral, por categorias ou tags
Para listar só com number posts é a quantidade de postagens
<ul> <?php global $post; $args = array( 'numberposts' => 10000); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul>
Agora se quiser pegar posts da mesma categoria e ordenar, por ASC ou DESC
Asc
mais antigos,
e DESC
mais novos
use cat =>104
104 é o numero da categoria
'category_name' => 'html'
html é o nome da categoria,
Use um dos dois
Veja o exemplo
Vou mostrar 10 postagens da categoria 103 e os mais antigos.
<ul> <?php global $post; $args = array( 'numberposts' => 10, 'cat' => 103,'order'=> 'ASC' ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul>
<< Anterior Como listar todas as categorias de uma postagem wordpress
Deixe um comentário