Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 months 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 (2)

#1 @scribu
9 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

This ticket was mentioned in Slack in #core-editor by karmatosed. View the logs.

9 months ago

Note: See TracTickets for help on using tickets.