Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#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:


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 (1)

#1 @scribu
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

This is already fixed in the 3.1 branch. See #16742

Note: See TracTickets for help on using tickets.