[wp-trac] [WordPress Trac] #12239: orderby and stiky post won't work as expected
WordPress Trac
wp-trac at lists.automattic.com
Mon Feb 15 15:14:12 UTC 2010
#12239: orderby and stiky post won't work as expected
--------------------------+-------------------------------------------------
Reporter: lifeless85 | Owner:
Type: defect (bug) | Status: new
Priority: high | Milestone: 3.0
Component: General | Version: 2.9.1
Severity: major | Keywords: orderby, stiky, Wp_query
--------------------------+-------------------------------------------------
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.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/12239>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list