You need to hook into the query because the category archive page explicitly only includes the ‘post’ type and nothing else.
function namespace_add_custom_types( $query ) {
if( (is_category() || is_tag()) && $query->is_archive() && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'post_type', array(
'post', 'myposttime'
));
}
}
add_action( 'pre_get_posts', 'namespace_add_custom_types' );
Modified from this article on CSS Tricks.
Related Posts:
- Filtering a custom post type by custom taxonomy in archive template
- Displaying category archive of custom post types
- Regex problem in an add_rewrite_rule
- get_categories for custom post type and filter by custom taxonomy (brand) and list child categories of a defined category
- Category page only displaying the posts from a custom type
- custom taxonomy archive by year
- CPT Archive with core Category
- Custom Post Type Archive Page Filtering
- Archieve.php not loading for custom post type
- multiple custom post type on category page
- Archive Template being used instead of Category Template for Custom Post Type
- Menu’s breaking, now showing all page links on site
- Advanced archive url structure (category, tag and date)
- Display all Categories except ones with a specific parent
- Custom WordPress theme not displaying posts from category
- Adding Custom Post Types to category/tag/author archives breaks header content
- Custom category taxonomy – archive page not showing up
- How can I generate a list of post-type specific categories?
- Custom Post type archives / categories give 404
- archive.php can’t find categorized posts
- How can I set up the URL for a category archive for a custom post type?
- Categories in custom post types
- Stop header code from showing in category page?
- Custom Post Type Archives by Year & Month?
- Page is defaulting to archive page and not designated template
- Show Custom Post Type by Author
- Custom post type archive with pagination?
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Taxonomy structure of Sport site
- Custom Post Type with static page for archive
- get custom post type categories
- Custom post types and permalink
- Search doesn’t find tags or categories in custom post types
- Second Custom Post Type Archive
- Get Post Primary Category
- How to show the archive / post type description on Single templates
- is_main_query() not working for WP REST API
- How to add custom post types to normal category pages
- Add category attribute to custom shortcode
- Linking to the most recent post in a Custom Post Type
- Posts from all the categories are being displayed instead of particular category
- Categories sorting
- How can I make my custom posts appear in their assigned category url?
- Allow user to set custom order to a list of custom taxonomies?
- forming WP_Query for posts of all post types but from specific categories
- PHP variable not regenerating when publishing multiple posts at the same time
- Custom Post Types with a common category for a blog listing
- Why is my site using index.php instead of archive?
- Custom post type archive page blank
- How can I get this request to use the Custom Post Type page template instead?
- category page for custom post type
- Getting used tags per post type
- Why does accessing url by category cause issues with post types?
- How can I use archive-{post_type}.php theme template?
- Navigate posts with different post type that are in the same categories
- Taxonomy archive 404ing (not term archive)
- Why does my taxonomy have a category style div id?
- Unable to edit categories in custom post type
- Custom Post Type setup
- Restrict category access to specific users/groups. Author always has access
- How to get Custom Post Type with Categories wise in WordPress using wp_query
- get_terms() parent, child and grandchild
- Custom Post Type Custom Archive Page Not Working
- Need to have an archive widget which organizes and displays a custom post type using a custom date field
- pre_get_posts works in post type archive but not in single post
- 4 posts per page from single category
- Retrieve Custom Taxonomies with Description and Slug
- users post count
- How to set “section categories”?
- Cannot use object of type WP_Error as array display category
- Cannot get to work tax_query array for terms
- Custom Post Type archive page listing a 404 or single post
- Page + Custom Post Type with same category
- Custom post type pagination problem – page 1 and 2 show same content
- The page or ad listing you are trying to reach no longer exists or has expired
- One of my headings is mysteriously coming up as a link in my CPT Archive
- Loop through a specific parent category
- Query the title of the page to show posts with matching category in the loop
- I broke it! Custom post type archive gets redirected to home
- How to Show all Values in category.php page using post_type
- Can’t seem to filter wp_query by current category ID
- Custom post type URL – filter by taxonomy
- How to query all custom posts of a certain type and checking what category they have
- Post Editor: display categories from current post type taxonomy only?
- Having some trouble properly displaying Custom Post Types in templates
- Customize category URL
- Custom Post Types Archives and daily/monthly joke
- How to make a list of posts displaying them 5 by 5 with a “next posts” link?
- Query Custom Post Type and sort by year
- Custom post types not using archive structure
- Custom post type and category permalinks
- Bulk edit for custom taxonomy
- show only one category posts in admin
- display all posts in current category
- How can I show second most recent post in sidebar, if most recent post is open in the browser?
- How to separate posts by categories?
- WordPress CPT archive page display sticky post first and then display the rest of the posts in same Query
- Remove date rewrite rule for custom post type archive page
- Taxonomy term archive claims there are no posts, but there are. How to resolve?
- How do I edit this code so that it also adds specific meta data into the user and subsequent CPT being created?