Working code for you:
// Set any Custom Post Type to be displayed on the archive.php and tag.php
function category_tag_archives($wp_query) {
if ($wp_query->get('category_name') || $wp_query->get('cat') || $wp_query->get('tag')) {
$wp_query->set('post_type', 'any');
}
}
add_action('pre_get_posts', 'category_tag_archives');
Related Posts:
- How do I get the current edit page ID in the admin?
- Does hooking into the same action multiple times drain memory?
- Disable visual editor on one specific page
- How to display random users with avatars
- Apply custom role capabilities to administrator (without plugin)
- Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php?
- In a WordPress plugin, how do you output HTML code inside the DOM header? [closed]
- Different ‘WP_CONTENT_URL’ for different subsites in Multisite setup?
- Linking thumbnail to full size image
- is_front_page not working in functions.php
- VERY new to coding – keep breaking site trying to add to functions.php
- Preferred Use of home_url()?
- How to enqueue JavaScript for specific WordPress pages only?
- Passing HTML in WordPress Shortcode arguments
- Functions.php reverted to new one
- Exclude Empty Child Categories in Menu
- Get page slug and assign a variable within functions.php
- Convert User ID’s to User Names in a single.php file
- Custom roles can’t access to wp-admin
- How to specify which Gutenberg blocks are available in the editor for a page template
- Refactor create_function
- Custom Shortcode, functions PHP WP_Query loop
- Attach parent category template to all subcategories
- How to insert a text in all pages and posts before or after specific places?
- Add class or ID to any WordPress function
- How to filter out shortcode when displaying the_excerpt() in the loop?
- wpautop – disable tags, keep tags
- How to remove howdy dropdown menu content
- Change Admin Bar “Visit Site” URL
- exclude a category from a search on a specific page
- How do I pass arguments for multiple functions hooked to a single action?
- Stop turning small dashes into longer ones
- Execute function after a post has been published
- Last updated date function
- Possible to display shortcode based on the category?
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- How to set default archive image without overriding first attached image? [closed]
- Toggle User Roles with button
- Passing a variable via wp_head and then calling it on the page
- Load Woocommerce and WordPress Functions Outside
- How to make custom column Admin>Users sortable?
- Theme functions.php file auto delete everyday [closed]
- Two Types of settings in WP – The Doubt
- How to know which ajax file or function is called for action
- How to filter $content in shortcode function
- Generating dynamic css into custom file [closed]
- How to call particular funcion when the check box is checked in plugin options page
- Difficulty with PHP function that displays a post’s format in WordPress
- Events: Check for other event with same start date and category [closed]
- Function coding error concatenating quotes I think
- Need print logo without any ID & class
- Can we create our own theme’s function.php?
- Not all CSS elements transferring via parent to child?
- Reset postdata not working on WP_Query in functions.php
- Filter nav menu items HTML tags and wrap inner text with span
- wp_enqueue_script | Help me figure out what is causing jQuery is not defined
- Using Static HTML instead of the `home_url()` WP function
- How to append classname to body tag if guest user
- add_filter to specific WooCommerce Category
- Why is it so hard to add a class to the tag in the sidebar widget?
- Parent theme styles overriding child theme CSS [closed]
- Need To Change WordPress Meta Tags… Includes wordpress shortcodes
- Adding theme option values as custom body class
- How to add a new image size and apply it to posts only?
- Can I include a custom PHP function in a WordPress function?
- Function to replace comment’s accented characters before posting
- wp_nav_menu work in functions.php but not in the theme
- Only echo Page Content (not page title & page content together)
- How do I preserve changes to a theme’s functions.php across updates?
- Unable to Change “Pages:” Before WP_LINK_PAGES
- Multiple, Dynamic, Sidebars Problem – First Sidebar not working properly
- Looking for Functions File that doesn’t Exist
- Fetch URL parameter
- Updating custom query var with multiple values
- Redirect to one of two pages after data submitted, depending on the current url
- WordPress wp_dequeue_script remove all other scripts
- Ajax Form Issues using Lightsail (AWS)
- Add Javascript code to functions.php childtheme
- Problem with my footer after changing WooCommerce Products Sorting [closed]
- Limiting WordPress Search function : Custom build
- Why does my wp_enqueue_script() only insert the script for logged in users
- Function stops working
- method to fetch entire tag list on archive.php
- MCAPI.class.php showing some error
- Remove post from latest posts after a month only with certain tag
- Custom taxonomy check box now showing up
- Set display name from nickname with register process
- How to prevent multiple custom terms from being created
- revision id is one number behind – publish_post
- Limit Number of Posts on Blog Category Page Throwing 404 Error on Paginated Pages
- How can I return the result of my custom function?
- Multisite Admin Roles
- Database SQL Error, Should Work
- wordpress not calling peliegro functions.php?
- Sanitize html, where to sanitize
- How to display data from custom fields in my custom shortcode?
- function to return comma separated list of meta values
- Creating mixture of shortcodes to use in the visual/text editor
- Get all users from role and add to dropdown (select) – wordpress, javascript
- WordPress enque the same script causes the setInterval not to work