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?
- Category Specific Archive
- Is there a plugin that will completely remove the category system?
- How to get only the last child of category slug?
- How do you remove display of WooCommerce product category on single product page?
- Show recent posts in menu?
- How to check category of of custom post type or not
- Set a them for all subset of category
- How to query post like normal search would do. within search.php page
- WordPress Get Posts from each category equally
- Unwanted Duplicate Product Categories in WooCommerce
- Why custom taxomony not showing when create a post?
- wp_list_categories with show_count, except for specific categories
- Adding a H1 Tag to Post Tags automatically, but hide the tag? (Same for Category)
- Retrieve post tags from from main wp_query
- Listing Post Categories on Home Page
- Get posts in a subcategory of a chosen parent
- How can I only display links from a child category
- Category Template – Show Last Entry as Featured
- can I ‘combine’ categories as a menu item?
- Hide category name but show posts
- Show the parent taxonomy by creating shortcode in woocommerce?
- Post List by category and under custom taxonomy
- Balance Tags to the_content Words Length
- How to create template for children category?
- Categories and Tags Conflict after Woocommerce Installation
- Show parent category if there is no subcategory
- Display a category name automatically using code in the functions.php file
- Removing categories, Comments etc from posts?
- Problem importing categories and sub-categories
- how to ask if in two categorys inside if
- How to show video from wp option value?
- Changing Woocommerce categories programatically
- Add an Exclusive or featured tag line to article titles
- How to list out post category name and description in page
- Print child category slug nicename
- Order Categories by Character Count