Last active
December 17, 2015 10:29
-
-
Save paulgibbs/5595124 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
// Not tested, but it should work | |
function pg_adjust_main_query( $query ) { | |
/** | |
* If we're not on the blog posts index page, | |
* or if we're not modifying the main query, | |
* then bail out. | |
*/ | |
if ( ! $query->is_home() || ! $query->is_main_query() ) | |
return; | |
$query->set( 'meta_key', 'YOUR_META_KEY_HERE' ); | |
$query->set( 'orderby', 'meta_value_num' ); | |
} | |
add_action( 'pre_get_posts', 'pg_adjust_main_query' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment