#12239 closed defect (bug) (worksforme)
orderby and stiky post won't work as expected
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | high | |
Severity: | major | Version: | 2.9.1 |
Component: | General | Keywords: | orderby, stiky, Wp_query |
Focuses: | Cc: |
Description
i've discovered that if i use orderby parameter in my Wp_query, stiky posts don't get on top, i was expecting that they remain on top and sorted too by the parameter i've decided because i was not passing caller_get_posts.
for example this fits to:
query_posts('orderby=meta_value&meta_key=from&order=ASC');
or
query_posts('caller_get_posts=0orderby=meta_value&meta_key=from&order=ASC');
by now the simplest way we have to do this is to do two custom loop and count the outputted posts like this:
$sticky=get_option('sticky_posts'); $args=array( 'showposts'=>2, 'post__in' => $sticky, 'caller_get_posts' => 1, 'orderby'=>'meta_value', 'meta_key'=>'from', 'order'=>'ASC' ); //do the loop here $args=array( 'showposts'=>2, 'post__not_in' => $sticky, 'caller_get_posts' => 1, 'orderby'=>'meta_value', 'meta_key'=>'from', 'order'=>'ASC' ); //do the second loop here
Notice that if we want 2 post we need to count how much have been outputted or they will be 4.
I've marked priority high because if people starts to use this features massively probabily fixing it in the future, would break backward compatibility for future versions.
Change History (4)
#3
@
14 years ago
- Resolution set to worksforme
- Status changed from new to closed
I can't replicate the issue with the first query_posts
example given. There is a typo in the second
query_posts
(missing
&
before
orderby
), the ordering of resulting posts from the typo'd version is a bit weird but I cannot replicate it with the corrected
query_posts
. Was testing using TwentyTen.
Recommend closing.
I am unable to duplicate this using Trunk & 2010 theme (as of 04/24/2010)...