/ / WordPress mostrando mensajes y límite - wordpress

WordPress mostrando mensajes y límite - wordpress

Tengo un problema muy serio con la visualización de la publicación en wordpress. Solo quiero un ciclo regular para limitar, por ejemplo, en 5 publicaciones por página y quiero mostrar los enlaces siguiente y anterior (página anterior y página siguiente)

<?php $latest = new WP_Query("showposts=2"); ?>
<?php while( $latest->have_posts() ) : $latest->the_post(); ?>
<article class="blogArticle">
<h2><?php the_title(); ?></h2>
<h3><?php the_category(" "); ?></h3>
<?php echo get_the_post_thumbnail(); ?>
<?php the_excerpt(); ?>
</article>
<?php endwhile; ?>

Respuestas

0 para la respuesta № 1

Para limitar a 5 publicaciones, necesitas usar el posts_per_page / numberposts argumento, no showposts. También puede configurar Wordpress para que muestre 5 publicaciones de forma predeterminada y omita la $paged y query_posts() parte.

<?php
// You can omit this block by changing the number of posts on WP Admin > Settings > Reading > Blog pages show at most
// Used to control pagination
$paged = (get_query_var("paged")) ? get_query_var("paged") : 1;
query_posts("posts_per_page=5&paged=".$paged);
// Omit above if you set the number of posts per page in WP Admin
?>
<?php while( have_posts() ) : the_post(); ?>
<article class="blogArticle">
<h2><?php the_title(); ?></h2>
<h3><?php the_category(" "); ?></h3>
<?php echo get_the_post_thumbnail(); ?>
<?php the_excerpt(); ?>
</article>
<?php endwhile; ?>

Para manejar la paginación necesitas agregar llamadas a ese funciones de paginación fuera de su bucle.

<?php next_posts_link("&laquo; Older Entries") ?>
<?php previous_posts_link("Newer Entries &raquo;") ?>