You can use pre_get_posts
to hook in and change the query.
The argument passed to pre_get_posts
is the query object. It fires for every query, so you need to check some things first. Quick example (not-tested) — change the order on only the video type’s post type archive page.
<?php
add_action('pre_get_posts', 'wpse73991_change_order');
function wpse73991_change_order($q)
{
if(
is_admin() || // no admin area mods
!$q->is_main_query() || // make sure we're modifying the main loop
!$q->is_post_type_archive('videos') // is this the video archive? (you might need to change this)
) return; // bail, we're not where we want to be.
// change the order
$q->set('order', 'title');
}
Related Posts:
- Categories sorting
- Custom post type, organized by categories
- WordPress posts page for customer filtering and sorting along with category filter
- How to sort post category using its Description
- How to sort custom post’s category by id from the theme’s function.php?
- Test if a Category contains certain Custom Post Types
- Custom Post Types with a common category for a blog listing
- Can’t remove front from permalinks for custom taxonomy category page
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- How to get categories linked in posts for a specific post type
- Custom post type showing index.php
- redirect automatic page that serves custom posttype content
- How to display “Category and Post_tag” component in a CPT Gutenberg edit screen?
- WooCommerce sort products by the actual product width(not the shipping width)
- Remove CPT name from permalink but add %category% instead
- Set a checkmark in a category based on a URL-parameter
- WP Query with categories only shows one post and ignores the category
- Adding custom post type to count in category
- How do I check if the user is on a taxonomy term parent, child or grandchild page?
- Sort and filter custom post type posts by custom taxonomy
- How to edit this code to get the categories in achieve page?
- Category with post type pagination returns 404
- Custom Post Type and Category Base Rewrite Issue
- Get the category from custom post type
- Post injections into Site Origins Page builder [closed]
- Custom Post Type + Categories
- How to create a gallery page with categories?
- WordPress Doesn’t Generate Taxonomy Archive
- Custom Post Slug same as Parents Category Slug
- CPT Template Not Showing – Getting 404
- I am having Trouble to get list of Categories of Custom post Type
- Hierarchy and access control for Custom Post Types (CPT)
- Multiple (two) category postings on the same page.
- manage_edit-{post_type}_sortable_columns sorts, but wrong!
- Loop filtering Custom Post Types and/or Categories
- Sort entries by date mixing two post types
- School & class blogs: Categorize with categories or custom posts?
- Custom post type and category link together
- Why is my category template ignoring post type?
- Best method to make posts searchable, sortable and filterable – custom field, tag or category?
- How to get custom posts sub category link
- Not sure if I should create multiple custom post type [closed]
- Cross reference custom post types
- Order a custom post type admin screen by a second custom post type title
- Make a custom_post translatable
- Pre-selecting the category for a custom post type
- browse by category and tags?
- I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
- Categories filtering in new post
- Conditional statement for if archive page has posts which contain certain taxonomies/categories/tags, show those terms
- Custom post types and category archive
- List of Posts and Categories
- How can I show 1 featured post in a styled element, and the next few below differently styled
- How do you create a custom template to display a category with an image and related posts below?
- How can I list Custom Post Types created with the Types plugin under categories?
- List Taxonomies: Don’t list taxonomy if it has no post – depending on custom post-meta?
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Custom templates for a specific category
- How to sort posts in a custom post type by title in ascending order by default?
- CPT category hierarchy
- Categorise Custom Post Types
- WP the_posts() on single-cars.php get category link
- Category.php template for custom posts
- How to retrieve category of a post in have_post loop?
- Categories and tags for custom post types
- Create new custom post and post category of same name
- Tag page only display 10 posts
- category page for custom post type
- in_category for custom post types
- sort post types by amount of views
- Get parent category id from child category page for custom taxonomy
- Getting used tags per post type
- Archieve.php not loading for custom post type
- multiple custom post type on category page
- Custom post type sorting: alphabetical order
- Custom Empty Results page for my Custom Post Type
- Sort a custom post with ACF: Date Picker & Display Featured!
- Category archive in with conjunction with custom post type is empty
- Can I restrict category availability?
- WP_Query Custom Post Type if Category ID Equals
- Why does accessing url by category cause issues with post types?
- Custom post types and ‘new WP_Query’
- How can I have different content for different countries?
- How to add current custom taxonomy slug to body class
- Assign category a default post type
- Meta data (Tags and Categories) for Custom Posts not showing.
- Navigate posts with different post type that are in the same categories
- List Posts By Custom Taxonomy
- Sortable column containing numeric values for Custom Post Type at WordPress Backend
- get_category_link() for custom post type does not include custom slug rewrite?
- How to Display Posts From Category Within a Custom Taxonomy?
- Showing custom post type categories in the menu
- Disable custom taxonomy on admin bar
- Why does my taxonomy have a category style div id?
- Targeting categories in custom fields
- Creating Sections for Post Types
- Custom post types with categories in template
- Invalid Taxonomy
- Need help deciding on a taxonomy