OK, so you have few mistakes in there.
field
can beterm_id
orslug
, but notid
.tax_query
should be array of arrays and not an array.
So here is fixed code:
function exclude_category( $query ) {
if ( is_user_logged_in() && $query->is_main_query() ) {
$taxquery = array(
array(
'taxonomy' => 'project-type',
'field' => 'term_id',
'terms' => array( 94 ),
'operator' => 'NOT IN'
),
);
$query->set( 'tax_query', $taxquery);
}
}
add_action( 'pre_get_posts', 'exclude_category' );
It’s not tested, but I’m pretty sure it should work just fine.
Related Posts:
- Querying Term Posts in Loop
- How to divide Subcategories into pages of parent category wordpress
- Filtering a custom post type by custom taxonomy in archive template
- Exclude a category from WP_Query
- How can I list all the categories under a Custom Post Type (taxonomy)?
- How to build a complex page structure
- How to filter custom post types by custom category taxonomy
- Is there a way to use regular categories with custom post types?
- Add Custom Post Type to Current Query
- How to list all categories and tags in a page?
- remove support for ‘Categories’ for a custom post type
- Glossary with Custom Post Type
- Custom-Taxonomy as categories: Remove “most-used” tab?
- Order posts by (hierarchical custom) taxonomy terms and term children
- Filter get_categories() for taxonomy term in WordPress
- SQL to update custom post taxonomies
- Query multiple taxonomy in Custom Post Type
- Querying Posts by Taxonomy From Alternate Network Site
- Add filter to wp_list_categories and query what type of taxonomy-terms it use?
- Limiting number of custom posts shown on taxonomy page
- Include custom post type in “all posts”
- Custom edit post column – category not showing
- Displaying custom post type on category pages but not on blog listings
- Taxonomy list. Order by a specific custom post type count
- Include different loop templates in search query
- How to show custom taxonomy in the permalink?
- pre get posts changing the query
- Custom post type taxonomy template
- Custom/separate categories for custom post type
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Taxonomy structure of Sport site
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- Using pre_get_posts to Filter Posts
- Display Custom Category (taxonomy) Name in Custom Post Type
- get_categories() for only CPT
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- Show Post Count of a Category
- WP_Query search posts by custom post type and custom taxonomy
- custom taxonomy archive by year
- Get categories and descriptions from custom post type
- Custom Taxonomy – Tags Metabox is showing instead of Categories
- Combining custom post type and post category
- Is it possible to create a shortcode that will query a post based on taxonomies?
- Show Two custom Post type and their posts on category page
- How to filter custom taxonomy categories on archive?
- How to create new category for custom post type?
- Weird problem happening with custom taxonmy when creating/updating posts
- Insert HTML inside link in a walker
- Custom Post Types and independent Categories – complex Taxonomy
- Should I use custom taxonomy or custom post type
- Set menu active state for custom posttype and category, given custom taxonomy term
- Display all posts in main category and 1 subcategory
- Am unable to reset a query properly
- Custom Post Type Archive Page Filtering
- How to modify archive query with pre_get_posts to append CPTs?
- How can I auto-assign a CPT post to category in a custom taxonomy when published?
- Posts from all the categories are being displayed instead of particular category
- Get next and previous 3 posts in a term in single post page
- Conditional Statement custom post type category
- Custom Post Type With Categories
- Making certain categories of CPT not publicly queryable
- Search / Filter posts on Title/Content OR Tags
- Categories sorting
- Allow user to set custom order to a list of custom taxonomies?
- get_category_parents for custom post type taxonomy
- Get parse_query filter to return slug instead of id
- wp_list_categories() – current-cat class also inside posts?
- Showing posts from different categories and from custom post type
- Categories of custom taxonomy don’t show any posts
- How to display custom taxonomies with links in filter menu?
- Show a Category X’s custom post type on Category X archive page?
- How do I move/order posts with a tag to the end?
- Cannot add category or custom taxonomy from admin. WordPress site is hosted in Windows 16 server via IIS. No XAMPP or WAMP
- Hide parent categories when clicked, and show it’s childs
- Limit amount of posts made within a custom taxonomy
- Filter CPT posts by one or more categories
- Getting categories of posts under a custom taxonomy
- Can’t remove front from permalinks for custom taxonomy category page
- Specific query for custom post type
- How to edit this code to get the categories in achieve page?
- Display post content with respect to its title?
- Get a list of categories ids
- Query Only Show Text on Posts With Certain Taxonomy Tag
- Trying to create hierarchy between 3-4 custom post types
- Customize category URL
- how to limit query_post to first page?
- Category / Custom Post Type permalink issue
- Display a custom post type list by taxonomy term
- Listing custom post type items from a couple of custom taxonomies
- Return Custom Post Type Categories
- Remove slug from Custom Category Permalink + dual-category permalinks
- Highlight specific menu item when custom post is page
- How can I show second most recent post in sidebar, if most recent post is open in the browser?
- pre_get_posts causes Custom Posts appear under ‘Pages’ menu
- Is it possible for post and custom post type to share a category base slug?
- How to add categories to a custom post type using wp_insert_post($new_post);
- WP Query filtering by custom category not showing all relevant posts
- How to get the proper category in permalink with custom post type assigned to multiple categories
- Category display using conditions
- Search for portfolio tags & mixing portfoliotags and post tags