Since you need to target the post type archive page and taxonomy pages, you just need to extend your function to include the specific taxonomy archive pages. You can use is_tax()
to target these taxonomy pages
You can try the following; (You can just modify is_tax()
to target specific taxonomies or terms according to documentation)
add_action( 'pre_get_posts', 'cd_sort_staff' );
function cd_sort_staff( $query ) {
if ( $query->is_main_query() && !is_admin() ) {
if ( $query->is_tax() || $query->is_post_type_archive('staff') ) {
$query->set('orderby', 'meta_value_num');
$query->set('meta_key', 'sort_order');
$query->set('order', 'ASC');
}
}
}
Related Posts:
- Create a shortcode to display custom post types with a specific taxonomy
- Automatically sorting custom post type admin area by a custom field
- How make get_next_post() return first post when viewing last one
- Get all authors with at least one post of ‘custom post type’
- Returning search results by relevance, including Custom Post Types
- Exclude from search all custom posts which are NOT in a taxonomy term
- Remove tabs from media uploader for a CPT
- It is possible to get a list of post types asociated to a taxonomy?
- Sorting for each custom taxonomy
- Custom Post Type pagination when CPT ‘rewrite’ rule and a page have the same slug
- wp_insert_post custom taxonomy
- dynamically update permalink and title with the values of custom fileds
- ascending order custom post type
- New WP_query in template not working with CPT+category on some pages
- Custom Post Type rewrite redirects to homepage
- Displaying a specific post in a wp query by post id
- Append taxonomy terms as class names in markup?
- Custom Post Types vs Database Table where many (10,000s + ) of entries are possible/desirable
- Permalinks without post type
- Loop through posts of a custom-post-type (event) and create .ics (iCal) file?
- Custom search for custom post meta with pre_get_posts interferes with WP search
- How to call a custom post type with WP_query
- get_posts of Custom Post Type AND Custom Taxonomy
- Tag page with Custom Post Types not returning any posts
- Advanced or not so advanced pre_get_posts query
- Querying both pages and posts
- Pagination of Custom Post Types not Changing Posts
- How do I create custom fields for multiple post types?
- Pagination issue on category.php using custom post type query
- How to add custom field to view-edit post type page
- Pages are not saving due to custom post type
- How to get all tags of a custom post type by id
- save_post custom post type ? $_POST not working?
- Change the Custom Taxonomy URL Slug pattern
- Losing Nav Active State in Menu
- How to hook one custom post-types post to another?
- Load Next WordPress Posts With AJAX?
- Add a custom meta box for client to order CPT posts how they want
- Custom select query for taxonomies that have posts categorized in another taxonomy
- Add categories to a page with out using Custom Post Types
- Custom posts template page
- Gravity forms multiple posts generated by one form [closed]
- Add Previous/Next Buttons to CPT Single Pages Only
- CPT Columns doesn’t show categories
- Role capabilities issue
- Dynamically insert code to custom post type loop
- Custom taxonomy template list not working (404)
- Showing User’s Post Counts by Custom Post Type in the Author.php?
- How To Post WordPress Custom Post Types to Twitter via IFTTT
- Custom Post Type Category URL
- Link From Single Post To Taxonomy Term Archive Page
- Query for post and costom post_type in same category filtered by meta for post_type
- Do I need to use another custom post type for 1 post that differs from all of the others?
- CPT as Product in WooCommerce
- Increasing the default number of posts in custom post types
- Calling related posts to a custom post type, taxonomy & Tag id
- How to get custom post type title, excerpt, thumbnail and permalink by post ID?
- Adding Page Ordering to a Custom Page Type
- How to properly use Categories with Custom Post Types
- Prevent user from editing others posts
- how to redirect to a custom post template
- Get post-meta value of all custom-posts – lowest to highest year-count?
- One Custom Post Type two different Templates
- Custom Post Type Query W/Category Dropdown
- How to get the custom post data using post id in WordPress?
- Should I use a custom taxonomy or custom post type for grouping a list of panels associated with a group of tests?
- Pin posts to top of custom loop
- Remove custom taxonamy slug with pagination
- Hook create / update post
- Change picture attachment meta of all occurrences of a picture
- Unknown Post Meta Records
- Custom Taxonomy – fields
- CPT Loop, include taxonomies and disclude others?
- CPT post doesnt shows tags and category on backend admin page
- Adding a nav menu for a custom post type
- Populate custom post type/custom fields from an external database
- Custom taxonomy- only output relevant terms
- Post types showing tables…Can I do that?
- Making my custom column sortable
- date_query won’t accept day parameter, but will accept month and year for a custom post
- the_permalink() leads back to homepage
- Registering an optional custom post type from a plugin
- Dropdown switching subcategories portfolio
- Weird capabilities / roles behavior
- 404 error Custom search results page for custom post types with friendly URL
- Prevent repetitive terms in get_the_term_list
- Generate custom RSS from a plugin
- How to Arrange Support => Thumbnail
- Filter custom post type by tags
- Displaying posts exclusively in their category (not parent)
- Can’t make permalink of CPT work
- Paged within a custom content type template [duplicate]
- is_singular won’t call my functions?
- loop through custom post-type with two meta_keys
- Generating custom URL before post is published
- Setting a Master Menu on a Custom Post Type
- How to add post type in masonry posts elementory widget
- How to exclude certain portfolios from a loop
- How do I add the “orange counter” next to a Custom Post Type?
- Custom slugs with dates & IDs on Custom Post Type