All of the cases you describe are handled by the post type archive, post type single, and taxonomy term archive pages that are all automatically generated (depending on arguments) when you register your post type and taxonomy.
function wpd_add_custom_types() {
// register fruit post type
$args = array(
'public' => true,
'label' => 'Fruit',
'has_archive' => 'fruits', // all posts of type fruit
'rewrite' => array( 'slug' => 'fruit' ) // single fruit
);
register_post_type( 'fruit', $args );
// register colour taxonomy
$args = array(
'label' => 'Colour',
'rewrite' => array( 'slug' => 'fruits/colour' ) // all fruits of colour
);
register_taxonomy( 'colour', 'fruit', $args );
}
add_action( 'init', 'wpd_add_custom_types' );
Related Posts:
- Filtering a custom post type by custom taxonomy in archive template
- Permalink Structure for Multiple Post Type Archives by Taxonomy
- get term archive url / link
- Pagination throws 404 error on custom taxonomy archive pages
- Archive page with multiple taxonomies rewrite
- Create permalink structure for one taxonomy archive per custom post type
- How to show a tag archive of one post type only
- Custom taxonomy archive page not working
- How to show multiple post types on taxonomy archive?
- Disable single pages and archives and keep preview
- How to create archive page for taxonomy terms within custom post type
- Category and post tag archives do not include posts from custom post type
- Get post type from taxonomy or category page
- custom taxonomy archive by year
- Display custom post type taxonomies as an archive page
- Archive page for taxonomy terms
- Custom Post Type Archive Page Filtering
- Root slug of taxonomy returning 404
- Create template for taxonomy results limited by Custom Post Type
- How do I check if the user is on a taxonomy term parent, child or grandchild page?
- Custom post type / taxonomy rewrite archive page 2 gives 404
- How can I get this request to use the Custom Post Type page template instead?
- Archive for a Taxonomy of a Custom Post type
- What’s the name of the custom post type yearly archive template?
- Custom Post type & Taxonomy 404
- Taxonomy archive 404ing (not term archive)
- Custom taxonomy or custom page templates?
- Dynamically insert an article at the top of a taxonomy archive – or?
- Only show posts with a specific term of an associated taxonomy in a custom post type archive
- Use the custom post type archive for taxonomies?
- How to rewrite custom taxonomy term archive to use THE SAME SLUG/front as CPT
- Get the link of the first post of a custom taxonomy in a custom taxonomy list
- Archive page for custom post type and custom taxonomy
- Advanced archive url structure (category, tag and date)
- How can I tell if I’m on a custom post type archive page?
- Custom Post Type Archive Page showing as 404
- Set up Custom Taxonomy Archive Template File To Cover 3 Categories
- How to show custom post count in archive page
- Order archive custom posts by taxonomy term [duplicate]
- Custom category taxonomy – archive page not showing up
- Custom post type URL structure with site.com/custom_taxonomy_slug/post_name
- Custom taxonomy archive slug overwrites static page
- Custom Post Type tag taxonomy “Page Not Found”
- archive-{custom_post_type}.php not getting recognized wordpress
- Archive.php is not displaying tags
- How to display custom post types AND regular posts separately on a shared taxonomy archive?
- Taxonomy Query of Custom Post Displays Archive Instead of Posts
- How to have a dynamic slug and rendering the archive-{post_type}.php?
- Show custom category archive as front page and remove taxonomy slug from urls
- Custom Post Type and Taxonomy URL rewrite
- How to build a complex page structure
- Proper way of making custom post type landing page or archive page
- Date archives for custom post type
- How to get_queried_object on multiple objects?
- paginate function in archive for custom-post-type
- Page to display an archive of taxonomies
- How to make custom posts to behave like taxonomy?
- List custom post type by custom tax term as page title
- Should I use custom taxonomy or custom post type
- Custom Taxonomy Navigation, with current menu items for children?
- Custom Post Type doesn’t show Draft and Trash Options
- A question on creating filters for custom posts using taxonomy
- Custom Post Type by Taxonomy
- count results in search page based on custom category
- Assign Custom post to Custom Taxonomy
- Trick to get custom post types to show up on a custom taxonomy page?
- How to add custom taxonomy in custom post type permalink?
- Combine multiple getEntityRecords calls
- Create an archive page for custom post type with custom taxonomy
- Custom URLs in post types make it impossible to view archive
- Custom Taxonomy Search result page
- Pull in taxonomy field of custom post type in new query
- Taxonomy template page not working
- Custom post type subtaxonomy template
- How to count other posts not having specific taxonomy terms?
- List all posts in taxonomy term
- Looping through custom taxonomy and display custom post types (Custom Post Type UI)
- set post_type based on custom taxonomy permalink
- Can’t Get Parent and Child Categories of Custom Taxonomy to Display
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Create a Dropdown Selector and Redirect for a Custom Taxonomy in WordPress?
- How to Implement Search Functionality?
- Search CPT by tag ids
- Custom post type 404 category page
- Post template with breadcrumb needs to show page navigated from
- How to associate custom taxonomy terms with custom post type?
- WP_Query not using custom taxonomy categories on custom post type
- Combine multiple separate lists into one
- Post Custom & Taxonomy 404 error
- Remove custom post type slug but keep related category taxonomy permalink
- page not found for example.com/custom-post-name
- Is it possible to add and display custom post types to an array?
- Custom post type and custom taxonomies display
- Timetable of Custom Meta Data using Custom Post Type and Custom Taxonomy
- Custom post type category page not working
- Adding rewrite rules to Custom Post-type mixed with Taxonomy
- Categories in custom post types
- Inserting two categories
- How to manage a bookstore
- Sort ACF by custom taxonomy