You must use two loops to do this. In the first loop, set posts_per_page to 5 and ignore_sticky_posts to 0. In that loop, add all IDs found to a ‘$do_not_duplicate’ array’.
In the second loop, set ignore_sticky_posts to 1, and post__not_in to the $do_not_duplicate array.
thanks buddy!
that’s quite illuminating.
I tried your method a couple of times, but still failed. could you plz help me look at the following code and tell me where should i put the ‘$do_not_duplicate’ array?
i now would like to have three latest sticky posts at the top of the list.
$sticky=array(
'cat'=>2,/*category to be displayed*/
'showposts'=>3,/*number of posts to be displayed*/
'post__in'=>get_option('sticky_posts'));
$others=array(
'cat'=>2,/*category to be displayed*/
'showposts'=>7,/*number of posts to be displayed*/);
/*the query*/
query_posts( $sticky );
/*the 1st loop*/
while ( have_posts() ) : the_post();
echo '<li><a href="';
the_permalink();
echo '" title="';
the_title();
echo '">';
get_short_title();
echo '</a><span>';
the_time('Y-m-d');
echo '</span>';
endwhile;
/*reset query*/
wp_reset_query();
/*the 2nd query*/
query_posts( $others );
/*the loop*/
while ( have_posts() ) : the_post();
echo '<li><a href="';
the_permalink();
echo '" title="';
the_title();
echo '">';
get_short_title();
echo '</a><span>';
the_time('Y-m-d');
echo '</span>';
endwhile;
/*reset query*/
wp_reset_query();
thanks again!
I have already solved the problem. thanks a lot!