Last active
August 26, 2023 23:46
-
-
Save BruceMcKinnon/c7440fee026f78cfefb50f76f8f8ebdf to your computer and use it in GitHub Desktop.
Add MenuOrder for postd
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
// Add menu order to the Posts edit screen | |
add_action( 'init', 'ingeni_add_posts_menuorder' ); | |
function ingeni_add_posts_menuorder() | |
{ | |
add_post_type_support( 'post', 'page-attributes' ); | |
} | |
// Reorder the loop sorting fro the the 'projects' category | |
function ingeni_change_category_order( $query ) { | |
if ( $query->is_category('projects') && $query->is_main_query() ) { | |
$query->set( 'order', 'asc' ); | |
$query->set( 'orderby', 'menu_order' ); | |
} | |
} | |
add_action( 'pre_get_posts', 'ingeni_change_category_order'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment