Created
September 21, 2016 14:32
-
-
Save jpen365/03d8a66145bc313c22d4b8de2fc799ca 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 | |
/* Sort posts on the blog posts page according to the custom sort order */ | |
function jpen_custom_post_order_sort( $query ){ | |
if ( $query->is_main_query() && is_home() ){ | |
$query->set( 'orderby', 'meta_value' ); | |
$query->set( 'meta_key', '_custom_post_order' ); | |
$query->set( 'order' , 'ASC' ); | |
} | |
} | |
add_action( 'pre_get_posts' , 'jpen_custom_post_order_sort' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment