WP_Query para UN solo post no funciona
27 jun 2012, 20:42:30
Vistas: 22.9K
Votos: 3
No importa qué haga, NO puedo encontrar por qué WP_Query obtiene todos los posts e ignora completamente posts_per_page
...
Solo quiero mostrar un post.
<?php
$args = array(
'post_type' => 'post',
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => -1 // Aquí está el error: -1 muestra todos los posts. Usar 1 para mostrar un solo post
);
// La Consulta
$the_query = new WP_Query( $args );
// El Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
?>
<div style="padding: 15px;">
<div class="grid_4 alpha">imagen</div>
<div class="grid_7 omega">
<?php the_excerpt(); ?>
</div>
</div>
<div style="clear: both;"></div>
<div style="height: 33px; background-color: #5ba4d8; position: relative;">
<div style="width: 300px; line-height: 33px;"><?php the_title(); ?></div>
<a href="" style="position: absolute; right: 0; top: 0;"><span class="nav-blog-next"></span></a>
</div>
<?php
endwhile;
// Resetear los Datos del Post
wp_reset_postdata();
?>

dcolumbus
647
Todas las respuestas a la pregunta
2
Preguntas relacionadas
5
respuestas