Created
October 31, 2012 04:10
-
-
Save peterwilsoncc/3984736 to your computer and use it in GitHub Desktop.
filter_pre_get_posts help
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function filter_pre_get_posts(&$query) { | |
if ( $query->is_home AND $query->is_main_query() ) { | |
$query->set('meta_key', 'my_key'); | |
$query->set('orderby', 'meta_value_num date'); | |
// should sort by meta-value as number, then by date | |
// actually sorts by date and ignores anything with my_key set | |
$query->set('orderby', 'meta_value_num'); //works as expected (sorts by my_key) | |
$query->set('orderby', 'date'); //works as expected (sorts by date) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment