By “last” do you mean the most recent or the oldest?
Thank you for your answer .
By last i mean the most recent
Are you customising the main query/Loop? Or creating a secondary Loop? If it’s the latter, you should be using
http://codex.wordpress.org/Function_Reference/get_posts or
http://codex.wordpress.org/Function_Reference/WP_Query
But the same parameters apply if you are customising the main query using query_posts().
am cutimising the main query loop
Try <?php query_posts( $query_string . '&posts_per_page=1' );?>
and for the $query_string what should i do in it ?
Nothing. Just try the code I posted above.
It posts only 1 post last post but not last post of each category :s
You have to cycle through all of the categories on your site and then use WP_Query – not query_posts().
<?php $all_my_cats = get_all_category_ids();
foreach( $all_my_cats as $my_cat_id ) {
$args = array(
'cat' => $my_cat_id,
'ignore_sticky_posts' => 1,
'posts_per_page' => 1,
'paged' => $paged
);
$the_query = new WP_Query( $args );
while ( $the_query->have_posts() ) : $the_query->the_post();
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
the_content();
endwhile;
wp_reset_postdata();
}
?>
Thank you so much you just saved my life.
Thanks alot