Last active
August 28, 2018 13:16
-
-
Save joshfeck/326c0a511afa8b829405157762f9f7a9 to your computer and use it in GitHub Desktop.
Manually re-order the Event Espresso People post type archive order with the Post Attributes -> Order field
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 | |
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
add_filter( | |
'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes', | |
'ee_modify_page_attributes_of_event_espresso_cpt' | |
); | |
function ee_modify_page_attributes_of_event_espresso_cpt( $cpt_registry_array ) { | |
if ( isset( $cpt_registry_array['espresso_people'] ) ) { | |
$cpt_registry_array['espresso_people']['args']['supports'] = array( | |
'title', | |
'editor', | |
'author', | |
'thumbnail', | |
'excerpt', | |
'custom-fields', | |
'comments', | |
'page-attributes' | |
); | |
} | |
return $cpt_registry_array; | |
} | |
// for the front-end | |
// change the post query’s orderby parameter to menu_order so the posts display in the defined order | |
add_filter( 'posts_orderby', 'jf_eea_people_frontend_archive_orderby' ); | |
function jf_eea_people_frontend_archive_orderby( $orderby ) { | |
if( is_post_type_archive( 'espresso_people' ) || | |
is_tax( 'espresso_people_categories' ) || | |
is_tax( 'espresso_people_type' ) ) { | |
$orderby = "menu_order"; | |
return $orderby; | |
} | |
// not a people archive, return default order by | |
return $orderby; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment