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
- Pagination not working with custom loop
- Display all posts in a custom post type, grouped by a custom taxonomy
- Have different number of posts on first page
- Display all posts starting with given letter?
- How do you get the count of posts in an archive page?
- How do I require authorization / login to view a specific set of posts / pages?
- Prevent pre_get_posts filter on specific post type
- group search results by post type?
- Set posts of a custom post type to be private by default?
- wp_pagenavi() with custom wp_query()?
- How to use a custom post type as front page?
- How to show Y number of custom posts after every X normal posts?
- $query->set in pre_get_posts is unintentionally affecting the backend
- Display Authors Comments on Profile Page
- List all posts commented by current user
- Fetching private posts or custom post types via WP-API with basic authentication
- How to put custom post types on front page
- Get Custom post with ID
- Custom Post Type Pagination Not Working On Archive Page
- Custom Post Type Archive Page: Set Posts Per Page, Paginate
- Add Custom Post Type to Current Query
- Display several random posts, but make sure a condition is met
- How to show more posts on an archive page?
- Include post id[s] into WP_Query()
- Category as Class for Custom Post Type
- Pre get posts for single post
- Archive page…limiting posts per page
- Adding custom post type to loop
- How to get my Custom Post Type to display in Recent Posts using “pre_get_posts”
- how do I group content in magazine-style ‘issues’?
- WP_Query to loop a Custom Field, Custom Post Types do not show
- Retrieving 3 latest post from each of 5 different custom post types
- Pre_get_posts Gives 404 on Custom Post Type
- How to query custom posts using a dynamic category
- WordPress “Loop” with large set of results
- filter search result with custom post type meta key
- Order posts by (hierarchical custom) taxonomy terms and term children
- Pagination go to first page if i’m on last post
- Grossly inefficient wordpress loops!
- Posts in Multiple Columns and Rows with one single loop
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Order custom posts by taxonomy?
- Newer/Older posts links display same posts on every page
- Best way to style first post differently?
- How Do I Use WP_Query to Run This Database Query as Search Result?
- How to solve suspected memory issue in custom WordPress loop?
- List events by month
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Conditional two level dropdown filter for custom post type
- Limiting number of custom posts shown on taxonomy page
- How do I write this SQL statement for Posts written in last 24 hours?
- Show all custom post type posts sorted by custom taxonomy then by another custom taxonomy
- Alphabetical sorting of custom post type – one letter per page
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- Include custom post type in “all posts”
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- Taxonomy posts on Archive page
- Group search results by post type, but hide post types with no results
- How to show posts from multiple post types in a single loop? And display them separately on the same template
- How to show related posts by category or custom post type?
- Fix custom query pagination without changing site-wide posts-per-page settings
- Custom post type loops with different page templates
- Randomly placed sticky custom posts complemented by blog posts
- How to create posts (not post template) to be displayed on projects page?
- Custom Post Loop in Archive returns same the_permalink
- Can’t sort order of wp_query with 2 meta keys
- WP_Query post at custom position
- Sort custom post types by last name in the backend
- How to display the rest of categories on Portfolio filterable
- Displaying custom post type on category pages but not on blog listings
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- 404 error PageNavi custom type taxonomy | wordpress
- Custom post type with tags
- WooCommerce – Show orders for a specific product ? [closed]
- Get_post_meta() won’t return value
- exclude custom post type by meta key in wp_query
- pre get posts changing the query
- Query for posts in 2 taxonomies
- Pagination with custom post types results in 404 issues
- Problems excluding a custom post-type from the loop
- Query Custom Post by Category
- How to get current post id of a custom post type in a loop using template singel-{custom type}.php?
- IF statement in a do_shortcode
- How do you output custom code between posts in the loop?
- Display all Posts and only certain Custom Post Types with meta fields
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- Get the title of custom post type in another loop
- How to append element after thumbnail
- How do I Use Nested Loops of Custom Post Types for MultiSite Blogs using WP_Query()
- Using pre_get_posts to Filter Posts
- ‘category__and’ for custom taxonomy?
- WP_Query and using a variable for ‘cat’=> in the args array = WP Bug?
- Disable comments from showing up public for Custom Post Type
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Posts navigation in custom post type single.php not working
- Displaying custom posts only if custom meta box’s date is not expired
- Integrating Orbit slider into wordpress through custom post type