Try using WordPress’ built-in filter for widget display called widget_categories_args
. You can add a filter function to your child theme’s functions.php
that modifies the arguments passed to the wp_list_categories()
function, which is what the Categories widget uses (if that’s what the widget you’re trying to modify) to pull its list of categories. Here’s an example:
function filter_widget_categories_args($args) {
$args['exclude'] = array(10); // ID of the category to exclude
return $args;
}
add_filter('widget_categories_args', 'filter_widget_categories_args');
The function filter_widget_categories_args
will modify the original $args
array by adding an exclude key.
Related Posts:
- Using wp_category_checklist in a widget
- How to remove the parentheses from the category widget
- How to create a widgetized sidebar for every category dynamically?
- Customizing Default Categories Widget
- Display all posts with same title
- I want to create a posts widget and be able to select categories
- How to have Multiple Archives Widgets, one archive widget per category (in a different page)?
- Categories lose hierarchy order once assigned to post
- Add Icons to the Product Category Sidebar Widget WooCommerce
- How to display widgets inside a page content without a plugin?
- How do you categorize pages?
- WordPress category widget only show categories with children
- Customize WordPress widget – Product Category
- Post Count for Categories, however not to calculate a total
- How do I make the category sidebar widget (stock) display the total # of posts including those in subcategories?
- Categories widget show empty?
- Is it possible to remove from default category widget?
- how to remove the default title of Categories widget
- How to show 5 posts from specific category on related page?
- display a widget on specific category and its sub categories
- Multiple selection for wordpress widget
- How to not display subcategories in Recent Posts widget area?
- How to Sync Menu, Widgets and other masters from Main Website to its Sub Site
- Tags Instead of Category
- How to hide widget from certain category
- Last x Posted Categories?
- WordPress category filters as subcategories
- exclude certain categories form archive widget
- Conditional widget for theme template file
- Add filter for specific category only
- Exclude a category from block editor’s category widget
- How can I display the category name in the single post when using WP Blog and Widget?
- How to Change Sort Order of default WordPress Catgory Widgets?
- How to add an “All” category to the tag cloud?
- Custom file with special code of category widget
- in_category(‘category-sluga’) returns true for Archive page of Category ‘category-slugb’
- Problem with single posts not showing correct category sidebar
- How To Disable Category Hierarchy In Categories Widget?
- single category widget with conditional terms
- Customize category query in widget
- What’s the URL for a category archive?
- how to use a different domain/subdomain for authors/catagories on single site?
- Category count inside the link
- Is there a way to have duplicate category slugs?
- Multiple level category drop-down
- How to add style to category link?
- WordPress Ordering Problem. How to fix ordering 1-10-100 issue?
- how to show posts of category random by session
- Remove “Parent” Selection When Adding/Editing Categories?
- Filtering search results
- WooCommerce change category url and product base
- How can we get Catergory / Term Creator
- Seperate WordPress catagories into sepeat list on seperate pages
- Redirect category to first available child post
- Show post only if match all categories
- How to get product count with respect to categories in WooComerce
- Display WordPress Parent Categories Only?
- Additional featured post on first page
- Assign automatically and manually modify category
- Displaying a full post instead of a slug per category?
- How do I toggle pagination on/off in search results and category listings via a link?
- get_categories() returns “Uncategorised”
- How to show WordPress parent and child category using a different template?
- How can I get categories IDs if multiple categories requested via URI?
- List categories with custom code
- WordPress for Podcast Network
- Exclude a category from a query that includes its parent category
- Count the posts number for every category
- Trying to get variables in hacked category dropdown
- Change of category structure will cause two kinds of URLs for one post
- Portfolio Filter Buttons Wont Work
- Get Meta Keys of Custom Categories
- Change slug of Standard wp Post category
- Hide a category of posts from main blog, and only show in category view
- ACF no print data [closed]
- Get the name of category in query
- Archive filtering
- Split multiple categories into two columns
- Add custom categories and subcategories and posts as custom pages
- pagination 404 error, same slug home and categories
- How can I order all subcategories alphabetical independent of the parent categories?
- Linking to the most recent post in my podcast category
- How to select a parent category and show the children to choose in another select?
- Subcategories in Category Page
- How can I display categories on different pages
- How to add excerpt and read more button to category archive page
- Icon images across multiple categories
- custom browse by
- How to get related category/categories in WordPress archive page
- Adding a button to a product if it’s in a category, then linking to that category
- How to add all categories into an array and extract the categories names and use it with a custom meta box
- Using pagination with multiple loops causes it to break
- get latest post in category date
- Query posts that have all the specified tags
- How can I show page per category in wordpress? (Yes, category by page!)
- Why does my category page display “posted on…” when all I want it to do is display categories?
- Remove category number fill
- Fetch all categories from database
- How to create a photo gallery that can be filtered by the image categories
- How can I get the categories and subcategories separately?