Last active
December 25, 2015 21:09
-
-
Save benhuson/7040848 to your computer and use it in GitHub Desktop.
WordPress custom order for main query
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
<?php | |
/** | |
* Post Order | |
*/ | |
function product_orderby( $query ) { | |
if ( $query->is_main_query() && ( is_post_type_archive( 'custom_post_type_name' ) ) ) { | |
$query->set( 'order', 'ASC' ); | |
$query->set( 'orderby','menu_order' ); | |
} | |
return $orderby_statement; | |
} | |
add_filter( 'pre_get_posts', 'my_orderby' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment