You can use the following code in your category archive template file.
if (is_category()) {
global $query_string;
$post_type = get_query_var('post_type');
if ( !$post_type ) { // if no post type is already defined
parse_str( $query_string, $args );
$args['post_type'] = array( 'post', 'you-custom-post-type-here' );
query_posts( $args );
}
}
You can also use the above code in any action that gets run just before the main loop.
Related Posts:
- New post status for custom post type
- Adding Custom Post Type Counts to the Dashboard
- How can I filter posts by post_parent in the admin?
- Get Custom Taxonomy ID within loop
- Rewriting ‘rewrite’ slug for custom post type used by plugin
- Using Templates with Custom Post Type UI
- WordPress Custom Post Type Admin Page really slow
- How to setup a Custom Taxonomy Term template
- Creating a gallery of featured images from custom post type
- Taxonomy terms with edit/filter link in wp-admin, in the list of custom posts
- Retrieve a specific field from taxonomy term through advanced custom fields [closed]
- Custom Taxonomy and tax_query Issue?
- Get list of terms of current taxonomy archive for another taxonomy
- Multiple information using custom post type
- WP_Query with custom post_type and cat retrieving unwanted posts with the custom posts
- Customize Search Results for Custom Post Type
- RSS feed for dynamic set of custom taxonomies terms
- Related links – from other sites
- Showing Custom Content in a Nav Dropdown
- Extend the wp_get_archives output with ‘?post_type=foo’?
- How to add a “custom” date field to a custom post type?
- Custom post type with file upload – need to “set as field” instead of “send to editor”
- Display custom post type category taxonomy
- WP Query—Relationship between two custom post types and their fields
- Are there sub-systems in WordPress that would employ data structures beyond CPT that a `get_posts` won’t be able to catch?
- ACF simple text field value not showing
- Create Custom Post Type Permalink Structure
- How to auto increment post title & post slug field?
- List Post Title by Last Word Then Second Last
- Query custom post type with tags
- How to check if user meta field is empty in conditional else statement
- How to stick custom post at the top in search results
- Custom Post Types don’t highlight in menu nav
- Display post as term id
- WordPress custom post type permalink rewrite shows page not found
- Callback to custom field is not working in WordPress REST API
- How to display post list inside post
- Create a Dropdown from Custom Post Type
- Display latest x posts from all categories in Custom Post Type/Taxonomy
- Custom post type conditional in loop
- Showing specific post in order of array wp_query
- Why cant I add a custom post type to a custom taxonomy?
- Show Custom Taxonomy title in loop
- Advanced custom field boolean value in custom post type
- the_post_thumbnail call removing li in code
- When should I create custom post types?
- How do you create %post_type%/%postname%/ permalink structure?
- How to display custom post type tags?
- Featured image size in column
- Submitting Custom Post Types with custom fields from Front-end form
- Custom WP_Query always respond with 200 status even when no entry
- Why would social icon badges disappear after adding a custom post type?
- Page Template Dropdown For Custom Post Types
- Get_the_terms restrict output
- Can I query posts by taxonomy conditionally based on post type?
- How to include category name/id in wp_query for retrieving “custom post type” from a particular category?
- Include custom post type custom taxonomies in Categories widget
- Sort custom post type by most current date picker
- Break up posts per page in two sections
- custom permalink for post only not custom post types
- post_content is stripping HTML when adding a new post? [closed]
- Querying a custom post type, but not show duplicates
- Save CTP post meta different values each day without overwriting previous values
- Changing CPT slug and taxonomy already registered in parent theme
- Dynamic category name in query post
- Show post count number assigned to custom taxonomy
- Two queries – one with checkbox ticked, one without – comparing meta_query
- Ignores post_type when no results
- Page-CPT.php redirects to archive or single.php
- Creating on-page options for Custom Post Type
- Check when the post type changes, and display content
- Can I decide what categories show on my posts page?
- Link custom post type to users membership
- WordPress – display relationship between blog posts and custom posts
- Multiple Loops In Tabs Only Displaying First Loop
- WP_Query to display number of custom post type filtered (order by) taxonomy
- Where is get_post_meta value located?
- Custom Post Type – Display all, wrap in groups of 3
- Display post in sequence from different custom post_type
- Sort loop by custom field from different post type
- Custom post meta box as a sub form
- Custom meta box data not saving
- Custom post type rewrite and wp_pagenavi interfering with each other
- WordPress loop, show only one post per custom field
- Getting list of Categories for Custom Post Types
- Adding Information To All Posts Screen
- Custom meta-box for all custom post types
- Retrieve a specific category of posts when using a custom post type
- General question about Parent and Child Post type relationships
- WordPress Load more posts by ajax not working
- Multiple while loops not functioning [closed]
- Listing all custom post types using a specific term on the said term’s template page, in groups
- Ideal top-level slug methods
- How to write an if statement which reads: ‘if is this custom post type or a child of it do the following’?
- taxonomies or categories w/custom post
- Require Custom Taxonomy for Custom Type
- Two blogs on same WP website
- Get post from custom post type that title is like custom string [closed]
- Custom Sort Order for Custom Post Type Taxonomy
- Load posts via AJAX without draft status