You could override your query with pre_get_posts
in functions.php
:
function add_all_fruits_to_category($query) {
$catnames = $query->get('category_name');
if ($catnames == 'fruits') {
$query->set('category_name', $catnames . ',bananas,apples,pears');
}
}
add_action('pre_get_posts', 'add_all_fruits_to_category');
Related Posts:
- Filtering categories in the permalink structure
- Multiple post categories – single permalink
- Handle category name URL rewrite before different post type slugs
- Categories’ hierarchy in URL
- Changing the category permalink structure
- Exclude subcategories from the url
- How to display only the parent category in the permalink
- Plural Category Base Slug On Category Archive Page
- Add specific word to default page permalink
- Get the category is not working on url
- How to set up Author archives with sub category URL
- force category base – archive pages work WITH & WITHOUT category base slug in url?
- Add “page-a” slug to category link if user visit category link from “page-a”
- One Specific Category To Permalink
- Read GET parameters in APACHE Mod Rewrite rules for WordPress categories in Posts
- Permalinks: display just one kind of wp category in the posts url
- Multiple URL’s based on category for one post
- Remove subcategory and category with some rules from permalink
- WordPress URL Rewrite for dynamic and customized URL
- Custom Structure permalinks error 404
- Category URL Management
- Remove subcategory slug from url
- Using custom structure prefix showing 404 for sub-categories
- A different permalink structure for different categories
- How to set the same base url for two different taxonomies?
- How to add a ‘News’ section to specific posts in WordPress
- Remove “category” from permalink with add_rewrite_rule
- WordPress Category url redirects to subdomain
- Create monthly archive for parent category
- hierarchical taxonomy in permalinks? using same slug
- Remove “?category=” in the URL wordpress ajax filter work for category
- How to change permalink structure for custom post type and it’s taxonomies?
- Multiple endpoints to same page
- How do I use the same post slug for different Categories?
- Custom permalink structure only for default posts
- Preserving $_GET parameter while using custom Rewrite Rule
- rewrite get parameter with custom post type
- Removing taxonomy base using WP rewrite
- URL Rewrite + Page + Custom Post Type = Unusual Redirect
- How to control which category will be picked for the slug of a post?
- Remove unwanted part of permalink custom structure from CPT url?
- Rewrite rules in .htaccess get overwritten?
- Getting add_rewrite_rule and add_rewrite_tag to work
- Passing & Reading URL Parameters with URL re-writing
- Permalinks for quote authors
- Prevent WordPress from automatically correcting URLs
- add_rewrite_rule and pagination issue
- Change Query String to pretty permalink
- rewrite rules for custom post-type with a custom taxonomy
- Remove special characters in a URL
- Alias ‘wp-content’ directory to something shorter (framework?)
- How to improve WordPress security by hiding non public facing files?
- open all .docs in word online
- url rewrite parsing a custom url parameter not working
- How to add custom variable in url without redirect?
- Pass a comment id through url and append the comment post’s slug in the url
- How to change the main site url on a multisite installation (network)?
- Is it possible to keep all special letters for foreign languages in slug as in title?
- optimize wordpress rewrite rule regex
- How to catch Rewrite rules then display a specific post?
- Login page is redirecting to homepage
- How do I get rid of “category” from my URL structure?
- Rewrite URLs – Custom Post Type – Post Slug, Taxonamy Slug
- URL Rewriting for PHP script on an image URL
- How to redirect specific URL to Subdomain
- How to add rewrite rule to custom post type with parent in url with cpt ui?
- Have different permalinks based on category
- Rewrite API -Adding a parameter before the slug
- Add /category/ to an author archive page
- IIRF + IIS 6 + WordPress does not return 404 error
- Is it possible to set the same base for categories and tags?
- Having WordPress control only certain pages with .htaccess?
- wordpress url correction
- My bbPress rewrite rules aren’t working
- Custom Post Type Category URL
- Adding URL prefix for foreign language support
- Category url generate 404 error
- add_rewrite_tag works for some parameters but does not for others
- Rewrite rule shows 404 page
- How to transform multiple parameter URL to clean URL
- Can I change the URL structure for a CPT only?
- Adding /blog in front of single posts (only)
- Exclude subfolder in WordPress permalink
- Help with .htaccess setup to hide WordPress Directory
- Ugly URLs when there’s pagination
- Hide wordpress source code
- Subcategory Page 404ing
- Prevent Archive URLs
- How to rewrite a folder in WordPress?
- URL duplicating after migrating domain
- Custom Post type and Custom taxonomy with URL rewrite worked but template did not
- Add dynamic url with external page in WordPress
- Using 2 URL’s for WordPress
- Changing Permalinks for Category Pages Only
- How to rename the WordPress wp-login.php running on IIS6?
- Generated URLs don’t reflect accurate URLs.
- Remove /category/ from category (archive) page URLs (without using a plugin)
- Rewrite rule to simulate page hierarchy results in 404
- Use same wordpress category base and tags as the prefix as the post permalink
- Custom post type Premalinks main page and details page