WP_Query mostra solo UN post, non funziona
27 giu 2012, 20:42:30
Visualizzazioni: 22.9K
Voti: 3
Non importa cosa faccia, NON riesco a capire perché WP_Query estrae tutti i post e ignora completamente posts_per_page
...
Voglio mostrare solo un post.
<?php
// Il problema è che posts_per_page è impostato a -1, che mostra TUTTI i post
$args = array(
'post_type' => 'post',
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => -1 // Cambiare questo valore in 1 per mostrare un solo post
);
// La Query
$the_query = new WP_Query( $args );
// Il Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
?>
<div style="padding: 15px;">
<div class="grid_4 alpha">immagine</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;
// Reimposta i Dati del Post
wp_reset_postdata();
?>
Tutte le risposte alla domanda
2
Domande correlate