Assuming you have a list containing the post IDs you want to exclude, you could start with something like (PHP 7.3):
function exclude_posts_from_category( array $cat_args ): array {
$exclude = array(); // TODO Add post IDs to exclude.
$cat_args['exclude'] = $exclude;
return $cat_args;
}
add_filter( 'widget_categories_args', 'exclude_posts_from_category', 10, 1 );
You can read about the widget_categories_args
filter here. Additionally, you can alter the $cat_args
array using a combination of arguments that can be found in the documentation of the wp_list_categories()
function.
I did not fully test this code, so let me know in case you’re having any trouble.
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
- wp_list_categories exclude not working
- 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 do I count how many top level categories there are?
- How to get the number of child categories a specific parent category has?
- 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
- Warning: sizeof (): Parameter must be an array or an object that implements Countable, On products pages
- 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
- Pagination is not working properly in Product Category/Tag pages
- There any way to get de percentage of number of post by user and category?
- WordPress category widget only show categories with children
- Get Number of total Parent Categories for Custom Taxonomy
- wp_list_pages() exclude category
- Single.php Category Post Count
- Exclude category from query
- Functions.php: Exclude Category from “Blog”
- If x comments in a post move post to category y
- Count tags for a specific category
- Show the amount of posts in a tag in a specific category has
- Woocommerce filter function not updating
- wp_list_categories not excluing multiple ids
- Change categories count to include media attachments
- 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
- Show the number of the post
- List all categories and count number of posts within based on custom date
- Count how many posts have a specified tag AND category
- 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
- Add subcategories posts to the counts column at the admin’s categories list
- Displaying Category in sidebar post widget but not in the loop on home
- Category menu that filters out empty categories
- Category count but only if category has at least one post
- 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?
- exclude certain categories from the list at the end of the blog post
- Exclude category when displaying all categories assigned to a post
- How to create an automatic MultiColoumn MegaMenu with Categories WordPress
- Is There a Difference Between Taxonomies and Categories?
- List all subcategories from category
- How To Find Out WordPress Category Table in MYSQL?
- Add custom field to Category
- Get Category ID inside Category template
- Only one category per post
- WordPress Multisite – global categories
- Get the children of the parent category
- Get posts from sites in Multisite?
- WP REST API: filter by category 1 AND category 2
- How To Get Parent Category Slug of Current Post
- Display All Products by Category with WooCommerce
- What is the difference between a “tag” and a “category”?
- Is there an easy way to make a meta box have the tabs like the Categories meta box has?
- How to check if I’m on the last page of posts?
- Display posts from the same category using next/previous post link
- How would I get a taxonomy/category list inside a Gutenberg block?
- Can I set a default featured image for a category?
- Check if a post is in any child category of a parent category
- How to export and import taxonomies (category, tag and/or custom taxonomy) and their terms
- Force category choice before creating new post?
- Gutenberg editor add a custom category as wrapper for custom blocks
- WooCommerce: List All Categories
- How to get category and archive title?
- Get category ID from category slug (not working)
- How do I remove “Uncategorized” from posts with more than 1 category?
- Get rid of WordPress category, tag and author archives?
- Individual rss feed entry length for categories?
- How can I create a category landing page followed by pages of posts?
- Remove parent category from permalink? Basically only have the child category?
- Custom permalink structure leads to be 404 on pagination
- Retrieve Product category ‘NAME’ by product category ID – WooCommerce?
- Posts URL structure like site.com/category/the-post-title