Right now, you can order by any of the stuff built into WP_Query using the shortcode:
[staff-directory orderby="title" order="ASC"]
For a totally custom order, Custom Post Types support menu order out of the box if you define it as such.
Since that isn’t already happening when Adam defines the CPT (this is your brainstorming!), you’ll need to add it yourself using add_post_type_support. Drop the following into the functions.php file in your theme (or, if the site has a custom plugin you’re maintaining, it’ll work there, too):
add_action( 'init', 'unique_prefix_add_staff_order' );
function unique_prefix_add_staff_order() {
add_post_type_support( 'staff', 'page-attributes' );
}
You should now see “Order” in the right column of the edit staff member page.
This will allow you to use the orderby
and order
parameters that Andy built into the plugin to order by menu order:
[staff-directory orderby="menu_order" order="ASC"]
If you’re not using the shortcode, but rather using the WordPress post type archives, and are therefore using a PHP template (if you have pretty permalinks on, it’ll be https://mysite.com/staff
), you’ll need to make sure that the query is being ordered by menu order. You’ll need to force that yourself using another filter called pre_get_posts:
add_filter('pre_get_posts', 'unique_prefix_order_by_menu_order');
function unique_prefix_order_by_menu_order($query) {
$post_types = array('staff');
if($query->is_main_query() && in_array($query->get('post_type'), $post_types)) {
$query->set('orderby', 'menu_order');
$query->set('order', 'ASC');
}
}
And those will work as well. Drop that wherever you dropped the add_post_type_support()
, but again – only if you aren’t using the shortcode.