All you’ll need to do is count() the get_the_category() results to determine how many categories your post is in, and check it along with your in_category().
For example:
while ( have_posts() ) : the_post();
if( in_category( $myCatsToExcludeArray ) && count( get_the_category( $post->ID ) ) == 1 ) {
do something
}
endwhile;
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 to exclude posts from a category when using this particular format
- Exclude category from Tag Template
- 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?
- Control term order on a per-post basis
- Display all posts from all categories with pagination
- Changing Top Level Items into Radio Buttons in the Categories Meta Box?
- How to create a widgetized sidebar for every category dynamically?
- Display the deepest child category from Category X (in loop)
- When using get_categories or similar, is it possible to filter results that contain certain Tags as well?
- WooCommerce – Display product child categories from specific parent
- Select category in custom query
- Show list of categories even if they have no posts
- How to control template resolution if both Author and Category filter in place?
- Resolved – category-slug.php not working after wordpress migration
- How to retain the values from dropdown category lists after wrong form submission?
- Get multidimensional array that reflects category hierarchy
- Add Post Screen Keep Category structure
- How to enable category hierarchy for links?
- WC 3.x Get categories from variable product of the cart
- Stick multiple posts in a single category
- Display category name on featured image in wordpress excerpt
- Is it possible to restrict viewing of category PAGE to logged in users only?
- Automatically adding categories and authors in custom menu?
- Second level subcategory
- how to define category loop last class in the third
- Automatically exclude categories from metabox based on title
- Making the category & tag Description textarea bigger
- Huge category CSV import does not work
- Needing a snippet for listing category specific tags
- Use Tag input metabox style for Categories
- Show matching categories in search page
- How to hide category name
- Keyword search in multiple categories
- How to do paging in the loop?
- query_posts not reading correct categories
- Displaying list of subcategories and not parent category
- Linking doctors posts to specific services for a medical practice
- Eliminate word from $term->name
- Showing HTML if Post is In Certain Taxonomy Term
- Category List with custom urls
- Get a list of all links on a page?
- Load the last post of a category
- create function to call category name and slug
- how to give different template to each subcategory from same parent category?
- No hierarchy in wp_list_categories with child of and depth
- global categories – Share specific categories in wordpress multisite
- WordPress update 4.7 – the 70.000+ news posts became “Uncategorized”
- Choosing different templates for categories
- Problem with wp_list_categories
- Display one post on category.php: Wrong featured image
- Changing Permalinks for Category Pages Only
- Taxonomy for custom post type not found
- How can I get this code to only output one link?
- Sorting Woocommerce products by category and attributes
- How to get Woocomerce categories count