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 create custom URL routes?
- How do you create a “virtual” page in WordPress
- Need help with add_rewrite_rule
- Mixing custom post type and taxonomy rewrite structures?
- remove “index.php” from permalinks
- How to create a front end user profile with a friendly permalink
- How do I add /blog/ as a prefix to permalink structure for blog posts, tag pages, etc.?
- Adding categories to custom post type in permalink
- Use a template file for a specific url without creating a page
- Using the Rewrite API to Construct a RESTful URL
- Does WordPress keep track of a post’s URL history and provide automatic redirects?
- How to rewrite URI of custom post type?
- Passing and retrieving query vars in wordpress
- Rewriting a custom-post-type permalink with taxonomy term?
- Change the “page” slug in pagination
- Understanding add_rewrite_rule
- Override default url for author pages?
- Permalink format: singular or plural
- Add .html (dot HTML) extension to custom post types
- How to change permalink structure for custom post type and it’s taxonomies?
- web.config conflict on IIS
- Rewrite Slug for CPT Archive Pages to Plural Name of Slug
- Change author base slug for different roles
- How does WordPress handle permalinks?
- Pretty permalinks for search results with extra query var
- Masking wp-content/themes/name/images to just images directory using htaccess
- Two (or more) parallel (sub-)TLDs that are retained when surfing the site / dynamically set the site address?
- How to get pretty URLs with add_query_arg in permalinks
- Using custom/dynamic “slug” for a page
- Remove parent category from permalink? Basically only have the child category?
- Custom rewrite rules for archive page and single post
- WordPress Rewrite Rules for Custom Post Type and Taxonomy
- Creating custom permalink structure for languages
- Custom post type permalink endpoint
- Custom permalink structure leads to be 404 on pagination
- How to make pages slug have priority over any other taxonomies like custom-post, post or category
- Posts URL structure like site.com/category/the-post-title
- Rewrite rules not working in WordPress
- How to get permalinks with category base working with sub-categories
- How to retrieve $_GET variables from rewritten URLs?
- Dynamic Endpoints
- How to remove dates from existing permalinks?
- Passing parameters to a custom page template using clean urls
- Use category base slug in posts’ permalink
- How to remove slug from hierarchical custom types in 3.5.2
- rewrite rules and querystring
- Getting the Site URL Including the Front Base
- Custom post types – Use post_id in permalink structure
- Using $_GET variables in the URL?
- Category archive by year with permalink support /category/YYYY
- Add a URL prefix to permalinks of one category of posts only
- Adding rewrite endpoint breaks static front page
- How to add custom rewrite rule to .htaccess?
- Multiple post types – share same ReWrite slug?
- Catch 404 after changing permalink structure from /%postname%/ to /%category%/%postname%/
- How do I remove a rewrite rule?
- How do I add a server-independent external rewrite rule?
- Multiple endpoints to same page
- Problem with add_rewrite_rule and pagination (paged and page query_vars)
- Use subdomain for certain urls
- Custom Permalinks for Blog Posts Only
- Unique URL Every Time
- Including category-base in a post permalink results in 404
- Custom post type permalink: only use %post_id% and remove %postname%
- Custom post types – Use post_id in permalink structure when using has_archive => true
- generate_rewrite_rules (action) vs add_rewrite_rule (function): which one is preferred?
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- WordPress thinks my custom route is a 404
- Detect page type by url (Archive, single, page, author,…)