Figured it out, it was simpler than I expected.
/**
* Include catalog posts in archives, even though they're not "public"
*
* @param WP_Query $query
* @return WP_Query
*/
function wpse415668_catalog_posts_in_archives(WP_Query $query): WP_Query {
if (! $query->is_admin() && $query->is_main_query() && $query->is_tax("catalog_category")) {
$query->set("post_type", "catalog");
}
return $query;
}
add_filter("pre_get_posts", "wpse415668_catalog_posts_in_archives");
Related Posts:
- Using pre_get_posts to filter one loop in a multiloop archive
- pre_get_posts works in post type archive but not in single post
- List all posts associated under custom taxonomy
- How do you get the count of posts in an archive page?
- Set posts of a custom post type to be private by default?
- How to show Y number of custom posts after every X normal posts?
- Fetching private posts or custom post types via WP-API with basic authentication
- Archive page…limiting posts per page
- Adding custom post type to loop
- Pagination go to first page if i’m on last post
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Limiting number of custom posts shown on taxonomy page
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- Taxonomy posts on Archive page
- How to show related posts by category or custom post type?
- exclude custom post type by meta key in wp_query
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- Posts navigation in custom post type single.php not working
- Unable to get post content from custom post type loop
- Display custom field of specific post where post title matches variable
- Remove duplicated values from a loop
- How to sort custom post type posts in default order by multiple fields?
- How to connect two custom post types with nested loops
- Pass the_post() as a parameter
- Comprehensively Restrict Post Type Taxonomy to Logged-in Users
- Normal pages as children of my Custom Post Type
- get_template_part and template file names
- Custom Post Type Loop throws 500 error when used in widget
- How to modify archive query with pre_get_posts to append CPTs?
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- Displaying CPT and custom taxonomy side by side in Bootstrap 4 component
- Group CPT posts by custom taxonomy
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- Display Custom Taxonomy Alphabetically
- Problem: wp_query outputs all images on site
- The loop seems stuck to a single (now deleted) post
- Custom Theme With Custom Loops
- Custom Post Types strange pagination problem
- Display related custom taxonomy posts in sidebar
- Targeting custom post type
- Conditional for a Single Post That Belongs to a Category?
- Using wp_query to modify the loop in index.php for a CPT
- Custom WP_Query doesn’t display all posts
- Query & the_content() is showing in the header
- Listing custom post types on archive page with array
- looping though custom post types and only return results in a given taxonomy
- How to conditionally add Custom Post Type to Front Page
- Pagination not working on custom query on a page
- Prevent A Specific Custom Post Type Showing In WP Search Results Page
- How to add a lightbox to class mix?
- get custom post type value in header.php [closed]
- Get post content from another section in custom single page
- get_terms() parent, child and grandchild
- Query all post types but limit to parents
- Custom post class, generate unique id from 1 to x depending on amount of posts?
- Create a custom taxonomy template that loops through child categories in term order?
- Custom PT, Taxonomys and wordpress query
- How can i loop through custom post type according to custom meta field?
- Changing WordPress sort order for returned child pages
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- creating a foreign key like relationship with custom post types
- Fetch data from two custom post types and create multidimensional array for output to html table
- Page that lists publications by classifying them by taxonomy
- Loop all post on single.php
- Exclude a specific post in a Custom Post Type
- Filtering posts based on three taxonomies
- Add extra elements to the_post in a custom post_type
- Custom Post Type has wrong label and is not found when called by a loop
- Combine multiple separate lists into one
- Error in the page of a CPT file in WordPress
- custom post type single page
- Custom taxonomy template for custom fields loop [closed]
- How to show terms used only for particular custom post type. Filter creation perpose
- CPT year wise archive based on custom date Field
- What’s the most efficient way to get two queries based on an if statement?
- 2 custom posts types, in their own columns, one pagination for both
- Custom post types not displaying per category
- How to show Y number of custom posts after every X normal posts?
- Custom post type with custom taxonomy permalinks
- Pagination on custom post types
- How to get past and upcoming post by defining date in custom field?
- How to query all custom posts of a certain type and checking what category they have
- Post data in separate divs with incrementing class using WP_Query
- Fetch post meta in the same query as the main loop
- Redirection loop error after login from a custom post type post
- Inserting random posts
- Loop to pull content from parent element in custom post type [duplicate]
- Post_type doesn’t work for widgets?
- How do I correctly query posts from a post ID?
- display custom post type from register taxonomy
- Custom post type and have_posts() return empty result
- why does my post loop break the page?
- How to create custom page templates with default page layout framework?
- display all posts in current category
- WordPress search results grouped by post type
- How to print different informations for different post types inside The Loop?
- How to insert a post from a different post type after every nth post
- Complex Custom Loop with Includes
- Sorting by Title for Post Archive Categories for Custom Post Type