Those look like curly apostrophes, not straight… try changing them to straight (all of them in your code) like this:
function add_custom_types_to_tax( $query ) {
if ( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
// Get all your post types
$post_types = get_post_types();
$query->set( 'post_type', $post_types );
return $query;
}
}
add_filter( 'pre_get_posts', 'add_custom_types_to_tax' );
Related Posts:
- Combining queries with different arguments per post type
- Create a shortcode to display custom post types with a specific taxonomy
- custom slug for custom post type
- importing third party json feed as custom post type [closed]
- List the categories under custom taxonomy
- Automatically sorting custom post type admin area by a custom field
- How make get_next_post() return first post when viewing last one
- Get all authors with at least one post of ‘custom post type’
- Returning search results by relevance, including Custom Post Types
- Custom Post Type Archives with 0 Posts Redirects as 404
- It is possible to get a list of post types asociated to a taxonomy?
- Sorting for each custom taxonomy
- Dynamic variable for custom taxonomy in loop?
- ascending order custom post type
- New WP_query in template not working with CPT+category on some pages
- Display posts of child category in template
- Custom Post Type rewrite redirects to homepage
- Displaying a specific post in a wp query by post id
- What hook should be used to programmatically create a post only when master post is updated?
- Prevent author role from editing all posts in custom post type?
- Want to turn WordPress into a paid subscription directory
- Using WPAlchemy metabox values in another metabox
- How can I change the title of an Add New page in Admin for custom post type
- Custom search for custom post meta with pre_get_posts interferes with WP search
- How to call a custom post type with WP_query
- get_posts of Custom Post Type AND Custom Taxonomy
- Tag page with Custom Post Types not returning any posts
- Featured Images does not show in custom post type
- Update menu when saving settings
- Pagination of Custom Post Types not Changing Posts
- How do I create custom fields for multiple post types?
- custom post type parsed as attachment
- How can I made custom taxonomies relationship?
- How to start a new post with custom Taxonomies already set?
- Pagination issue on category.php using custom post type query
- How to add custom field to view-edit post type page
- How to prevent a CPT’s slug and page slug from conflicting with each other?
- Pages are not saving due to custom post type
- How to get all tags of a custom post type by id
- How to Add multiple instance of meta box to custom post type
- Losing Nav Active State in Menu
- Manage Columns : order by post_parent’s title
- How to hook one custom post-types post to another?
- Limiting posts_join, where, etc to a specific WP_Query object?
- Add a custom meta box for client to order CPT posts how they want
- Custom select query for taxonomies that have posts categorized in another taxonomy
- What is the ID parameter for custom post types in query_posts?
- Add categories to a page with out using Custom Post Types
- Custom posts template page
- If there is only one post (show elements) else (show other elements)
- Gravity forms multiple posts generated by one form [closed]
- Add Previous/Next Buttons to CPT Single Pages Only
- Custom Post Types Archives and Single Pages not showing custom taxonomy data
- Role capabilities issue
- Dynamically insert code to custom post type loop
- Showing User’s Post Counts by Custom Post Type in the Author.php?
- How To Post WordPress Custom Post Types to Twitter via IFTTT
- Custom Post Type Category URL
- Link From Single Post To Taxonomy Term Archive Page
- Do I need to use another custom post type for 1 post that differs from all of the others?
- CPT as Product in WooCommerce
- Increasing the default number of posts in custom post types
- Better approach for a WordPress Inventory
- Showing all posts and custom post types by using one category
- Calling related posts to a custom post type, taxonomy & Tag id
- How to get custom post type title, excerpt, thumbnail and permalink by post ID?
- Prevent user from editing others posts
- how to redirect to a custom post template
- WP not recognizing custom post type / template
- Displaying Portfolio Filter by Category Order (alphabetically)
- How to create subdomain for custom post type and associated custom taxonomies
- How to get the custom post data using post id in WordPress?
- Should I use a custom taxonomy or custom post type for grouping a list of panels associated with a group of tests?
- Show only Current category and sub category of custom post wordpress
- Taxonomies are not showing in the category dropdown
- Add Pagination in custom Blog page template
- Unknown Post Meta Records
- Show Recently Viewed Custom Post to the visitor without plugin
- CPT post doesnt shows tags and category on backend admin page
- Adding a nav menu for a custom post type
- WordPress API only returning HTML
- Populate custom post type/custom fields from an external database
- Custom taxonomy- only output relevant terms
- Post types showing tables…Can I do that?
- Registering an optional custom post type from a plugin
- Dropdown switching subcategories portfolio
- Weird capabilities / roles behavior
- Prevent repetitive terms in get_the_term_list
- Generate custom RSS from a plugin
- How to Arrange Support => Thumbnail
- Filter custom post type by tags
- Displaying posts exclusively in their category (not parent)
- Can’t make permalink of CPT work
- Issue with permalinks for custom post type
- Paged within a custom content type template [duplicate]
- Generating custom URL before post is published
- Setting a Master Menu on a Custom Post Type
- Remove plugin’s custom post type archive page and single pages [closed]
- Multiple posts selection [closed]
- How to make a non-public post on wordpress approval?