If the URL to the ‘cancer’ taxonomy term in your example looked like this:
yourwebsite.com/topics/cancer/
then you could filter these results by post type with a URLs structured like this:
yourwebsite.com/topics/cancer/?post_type=question
Just put this in functions.php
add_filter( 'pre_get_posts', 'wp123_post_type_by_taxonomy' );
function wp123_post_type_by_taxonomy( $query ) {
if( is_tax( 'topics' ) && $query->is_main_query() ) {
// get all post types:
$post_types = get_post_types();
// or add specific post types:
// $post_types = array( 'post_type_1', 'post_type_2' );
if ( !empty( $_GET['post_type'] ) && post_type_exists( $_GET['post_type'] ) ) {
// show only results for this post type
$query->set( 'post_type', $_GET['post_type'] );
}
}
}
Related Posts:
- Custom Taxonomy as checkbox or dropdown
- Custom Taxonomy as Dropdown in admin
- WP insert post and custom taxonomy
- WP_List_Table Inside Metabox Not Working on Submit
- How to filter post data with AJAX on page?
- Custom permalinks
- Query multiple taxonomy in Custom Post Type
- automatically create taxonomy with same name as post title
- Separate Custom Post Type Taxonomy by Comma
- Maintaining WP_Query Relation Among CPT, Custom Taxonomy, Permalinks- CPT UI
- Add filter to wp_list_categories and query what type of taxonomy-terms it use?
- Custom post type category, taxonomy and URL rewrite problem
- Get child terms of current term of the current post
- Allow duplicate slugs for posts on Custom post type in different categories/taxonomy?
- Assign category to front end post
- How i add new link after Edit | Quick Edit | Trash | View in quick edit section
- Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy
- How loop through posts based on custom fields
- Listing taxonomies from custom post type
- Hierarchical Custom Post Types or Similar
- Custom Taxonomy Hierarchy for Custom Post Types (eg Categories and Subcategories)
- Output the content of a term organised by each of the CPT?
- How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- Generate Shortcodes by Taxonomy
- What is the use of a custom taxonomy?
- Is there a way to connect a custom post type to another custom post type’s taxonomy? (specific to locations)
- Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1
- I have 2 post types i need to show the post type contents in 2 select boxes [closed]
- wp_query check if integer exists in custom field’s array
- How can I set taxonomy programmatically
- Return the latest post from a custom Taxonomy and Post Type
- Don’t know how to show custom taxonomies from a custom post_type
- list taxonomies from a custom post type
- WordPress custom taxonomy, posts urls
- WordPress loop: Show only a Custom Post Type Taxononmy TERM
- Import data from CSV with custom taxomony empty
- Custom Post Type Loop with Query Var
- Full Custom Post Type List Organised by two Taxonomies
- URL rewriting for CTP assigned entity
- Template for all categories of a custom post type?
- How to group posts and get a mixed posts and groups view?
- Post format alternative?
- dropdowboxes with pre-selected custom fields optios that filters the results according seach needs
- Control content before and after custom post type loop
- post_type_link Filter – Too Few Arguments
- Show categories of custom post type and not all posts
- Reusable metabox backend and frontend
- Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]
- Archive page for custom post type and custom taxonomy
- Using page title as a link to term archive
- How to display posttypes and taxonomy in standard posts, not in a separate label?
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- Creating custom post type and taxonomy archives and pretty URLs
- Should i use custom post type for a custom footer?
- best way to use custom taxonomy, post type and meta in a job system
- Show 10 newest post for each value of a custom taxonomy
- Display the link of a custom taxonomy
- Custom taxonomy: on the taxonomy term page show other taxonomy terms
- Error 404 change permalink term custom term taxonomy
- Custom post categories are not displaying on the page
- get_posts wont produce a list of custom type from a given category [duplicate]
- Display Custom Field or Custom Taxonomy in front page /post/product
- CPT tags not showing when editing post
- WP_Query for custom taxonomies showing posts from non-specified terms?
- PHP Warning with Custom Fields
- Don’t share custom taxonomy terms if applied to multiple Custom Post Types
- How to show custom post count in archive page
- How to add independent “Tags” to Custom Post Type?
- Display custom tax in “while” loop
- Show posts under a selected custom taxonomy term
- Getting all custom post taxonomies and exhibiting only part of them
- Linking Taxonomies
- Get posts under custom taxonomy and custom post type
- Flush rewrite rules when new cpt is registred
- Shortcode in excerpt
- Custome post type “tags” pick default archive instead of custom post type archive
- How do I retrieve the title of a term of a custom post type with custom taxonomies?
- Show custom taxonomy not in submenu
- Custom Taxonomy is disabled on Edit page
- Single page archive – get coresponding taxonomy and terms
- How to assign custom post template to its custom taxonomy terms
- Excluding top level from taxonomy and post loop
- Custom Post Type and Custom Taxonomy not connected
- Displaying custom post types with taxonomy
- Get a list of categories ids
- How to Associate Posts with Pages
- Get link for feed of specific post type AND taxonomy
- Custom taxonomy archive not showing posts of certain child taxonomies
- Get single object term for custom taxonomy
- Custom posts and custom taxonomies for many products and categories?
- How to retreive terms associated with a custom post type?
- Return Custom Post Type Categories
- How do i get the taxonomy term name on the CPT archive page?
- Create taxonomy from Custom Post Type
- ACF Relationship: Group posts by parent category term, then child [closed]
- Calling custom taxonomies
- Limit taxonomy terms added to a custom post type
- I want to understand plugin implementation of custom posts / taxonomies / metaboxes
- Sort ACF by custom taxonomy
- Is it possible to use a post name in a custom post slug?