The solution was to replace:
if ( !is_admin() // IMPORTANT, make sure to target front end only
&& $q->is_main_query() // IMPORTANT, make sure we only target the main query
&& $q->is_category() // Only target category archives
) {
for:
if ( !is_admin() // IMPORTANT, make sure to target front end only
&& $q->is_main_query() // IMPORTANT, make sure we only target the main query
&& $q->is_category() // Only target category archives
&& $q->is_tax(get_query_var ( 'category_name')) // Only target existing category names
){
Related Posts:
- Post Pagination Showing Same Posts Every Page
- Completely disable RSS feeds on WP 5.5.2 and show a 404 page instead of die();
- How do I redirect all 404 error url to Subcategory url
- Variable if post is sticky in functions.php
- 404 redirect to previous category
- Difficulty with PHP function that displays a post’s format in WordPress
- WP function won’t work on 404 template page
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- Javascript file loads only on homepage, not on other pages (404 not found error)
- Unable to declare AOS library in functions
- How do I get the current edit page ID in the admin?
- 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
- Preferred Use of home_url()?
- Functions.php reverted to new one
- Get page slug and assign a variable within functions.php
- Make “sidebar template” the default template for new pages
- 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
- Logic to Print/echo a css class only for 1st post and ignore all post after 1st? [closed]
- 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?
- Remove Font-Awesome MaxCDN Link & Load Locally
- 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]
- 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]
- watermarking gallery items
- Function coding error concatenating quotes I think
- Need print logo without any ID & class
- Reset postdata not working on WP_Query in functions.php
- Filter nav menu items HTML tags and wrap inner text with span
- Change menu based on page template via functions.php
- 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
- Why is it so hard to add a class to the tag in the sidebar widget?
- Parent theme styles overriding child theme CSS [closed]
- 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?
- What is the correct way to include my new functions and scripts in WordPress?
- Function to replace comment’s accented characters before posting
- wp_nav_menu work in functions.php but not in the theme
- add_menu_page() with variable function
- Unable to Change “Pages:” Before WP_LINK_PAGES
- include w_thumbnail_src in function?
- Multiple, Dynamic, Sidebars Problem – First Sidebar not working properly
- Looking for Functions File that doesn’t Exist
- Redirect to one of two pages after data submitted, depending on the current url
- Ajax Form Issues using Lightsail (AWS)
- WordPress Sticky Post Count “Fix” Breaking Pagecount by 72 pages!
- 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
- how to remove a tag in the_category function
- Copying a widget class to functions.php results on a blank page
- How to create admin ajax function for my contact form
- No compression occurs on my jpegs after adding jpeg_quality hook to my functions.php file
- Changing the register url is not working
- Newest comments first not working
- how to display featured image for single post for a specific category
- Database Query not working
- Can I use a function to return HTML and the result of another function?
- save_post hook – headers already sent?
- How to use WP_rewrite?
- Wp get archive only text not link
- can not call functions in function.php
- Display post_meta-by_key on product catalogue
- What are the parameters are used in add_action and filters?
- Does functions.php apply to every page?
- Creating mixture of shortcodes to use in the visual/text editor
- User’s Comments Number: Storing it in a meta field for different uses
- Show one post per author and order by custom field
- Text before price on WooCom
- Warning: call_user_func_array() expects parameter 1 to be a valid callback
- Change Post status based on custom field date +1 day
- How to store page-{id}.php templates in custom folder