#17041 closed defect (bug) (duplicate)
pre_get_posts filter and orderby meta_value
Reported by: | ben.yitzhaki | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.1 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
When trying to sort posts using the "pre_get_posts" filter and ordering by meta_value, it doesnt seem to work. sorting by title date and anything else works perfectly.
a hint from the code:
function pre_posts_order($wp_query)
{
$wp_query->set( 'orderby', 'meta_value_numb' );
$wp_query->set( 'meta_key', 'custom_posts_order' );
$wp_query->set( 'order' , 'ASC' );
return $wp_query;
}
add_filter('pre_get_posts', 'pre_posts_order');
Change History (2)
Note: See
TracTickets for help on using
tickets.
This is already fixed in the 3.1 branch. See #16742