WP_Query pentru UN SINGUR articol nu funcționează
27 iun. 2012, 20:42:30
Vizualizări: 22.9K
Voturi: 3
Indiferent ce fac, NU POT să înțeleg de ce WP_Query aduce toate articolele și ignoră complet posts_per_page
...
Vreau să afișez doar un singur articol.
<?php
$args = array(
'post_type' => 'post',
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => -1 // Aici este problema - trebuie să fie 1, nu -1
);
// Interogarea
$the_query = new WP_Query( $args );
// Bucla
while ( $the_query->have_posts() ) : $the_query->the_post();
?>
<div style="padding: 15px;">
<div class="grid_4 alpha">imagine</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;
// Resetare Date Post
wp_reset_postdata();
?>
Toate răspunsurile la întrebare
2
Întrebări similare
1
răspunsuri