The wp_list_categories()
function uses get_terms()
behind the scenes, where the documentation for the exclude
argument says:
If
$include
is non-empty,$exclude
is ignored.
Instead you could try to exclude the term_id
from the include
values:
$include = wp_filter_object_list(
get_the_category(), // Data
[ 'term_id' => 1 ], // Filter Data
'NOT', // Filter Option (exclude)
'term_id' // Pluck Data
);
where we use wp_filter_object_list()
to both filter and pluck. In general it could be better to check if the $include
array is empty or not:
if( $include )
{
// ... stuff above ...
wp_list_categories( [
'include' => $includes,
'title_li' => '',
] );
// ... stuff below...
}
Related Posts:
- exclude category from get_posts?
- Exclude the category from the WordPress loop
- Exclude certain category from latest updates
- Exclude categories from Loop, queries, widgets, post navigation
- List posts by category exclude current post
- Excluding a category from next and previous post links
- Exclude Category From Home Page, Display Posts on It’s Own Page?
- How to exclude categories from recent posts, recent comments & category widgets?
- Exclude a category from the filed under list only on some templates
- How to exclude posts from a category when using this particular format
- Exclude category from Tag Template
- exclude post from displaying in loop if it is in a category, but not in many categories
- I need to create a search form that will display search results from specific category
- Exclude Posts From Specific Category from Next and Previous post links
- Query Posts Exclude Entire Category
- exclude categories from search results
- Exclude category from fucntion
- WordPress category widget only show categories with children
- wp_list_pages() exclude category
- Exclude category from query
- Functions.php: Exclude Category from “Blog”
- Woocommerce filter function not updating
- wp_list_categories not excluing multiple ids
- How to exclude posts from category posts count
- Exclude category from foreach loop
- Have posts that belong to multiple categories, exclude some categories from homepage
- Exclude all subcategories in the_category (post)
- I need to exclude from a query a category and a few custom taxonomies
- Exclude categories by ID
- Homepage custom recent news
- Exclude the category in WordPress
- How can I exclude a category from the main loop with the category name & not ID?
- User level categories
- Exclude category from drop down list form
- exclude certain categories form archive widget
- How to remove an item from a custom Walker_Nav_Menu
- Exclude a category and post_type from wp_query
- How can I exclude a particular category from my WordPress Page 1 and Page 2?
- Exclude category from WP_Query args not working
- Displaying Category in sidebar post widget but not in the loop on home
- Category menu that filters out empty categories
- Problems with explode [closed]
- Exclude Category From Home Page, Display Posts on It’s Own Page?
- How to have a category not show up in query post with page panigation?
- Customize category query in widget
- Call function on a single page
- Excluding cateory not working on my site. how to solve this? [closed]
- How to define category ID in an array?
- Get all categories and posts in those categories
- How to display non-hierarchical taxonomy as terms with checkboxes?
- Different templates for parent and children categories/taxonomies
- Remove child products from woocommerce category page [closed]
- Display comments on a comment page without form
- Plural Category Base Slug On Category Archive Page
- How do I view a feed consisting of posts from multiple categories?
- Marking old posts as no longer relevant
- Unpublish all posts in a category
- Add class to items in wp_list_categories()
- How is the single category page called and how does it know which posts to show?
- Is it possible to select and edit the way the most recent post from a certain category is displayed on the page?
- Extract image url associated to a category
- category filter doesn’t work in WPML
- How do you categorize pages?
- Order of subcategories
- “Categories” for six authors [closed]
- Category control subcategories
- Trying to add cat_ID to array for showing an image for specific Category
- display posts from specific category on a page , in thematic child theme?
- How to change amount of categories listed on dashboard?
- Display random categories
- Link To Child Category For A Post
- Post by category+author not working!
- Custom template for sub-sub-categories
- How to remove the tilte “category:category name”?
- why category__and and category__in wont work togather?
- Advanced permalinks structure
- Subcategory Page URL to Display Only Posts from that Subcategory?
- Shop Category Pages missing s
- How to prevent tag “iframe” from being deleted from the heading description of rubric?
- Some subcategories not working on custom portfolio sort
- How can I make a category function as a page?
- Link For Portfolio Categories
- Create duplicate category page with content variations
- Renaming default category taxonomy?
- Category names dependent on each other?
- Loop Through Categories in Custom Field
- Backend – Categories and Menus conflicts
- Loop through posts of CatA and store value of CatB in separate array
- Highlight posts that belong to current sub category
- How to add an empty entry to masonry?
- Problem with single posts not showing correct category sidebar
- Multiple Categories under one URL, where ‘Front Page’ is used already
- finding out the top 5 source ( source is a custom taxonomy ), in a given category
- How to display many photo albums related to category
- Modify functions.php to add a term ‘uses-theme’ set to theme name on post save
- WordPress category gives 404 after moving to a different domain
- Create custom Perma link
- Why does WordPress append a bullet to my category tag?
- how to implement next/prev within category archive?
- Add product category to post_class