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
- Exclude a category from WP_Query
- How to filter custom post types by custom category taxonomy
- Is there a way to use regular categories with custom post types?
- 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?
- SQL to update custom post taxonomies
- Query multiple taxonomy in Custom Post Type
- Add filter to wp_list_categories and query what type of taxonomy-terms it use?
- Custom edit post column – category not showing
- Displaying custom post type on category pages but not on blog listings
- Include different loop templates in search query
- pre get posts changing the query
- Custom post type taxonomy template
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Taxonomy structure of Sport site
- Display Custom Category (taxonomy) Name in Custom Post Type
- 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
- Insert HTML inside link in a walker
- Set menu active state for custom posttype and category, given custom taxonomy term
- Am unable to reset a query properly
- 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
- 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
- wp_list_categories() – current-cat class also inside posts?
- How to display custom taxonomies with links in filter menu?
- 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
- Hierarchy and access control for Custom Post Types (CPT)
- Best method to make posts searchable, sortable and filterable – custom field, tag or category?
- How to get custom posts sub category link
- List of Posts and Categories
- WP the_posts() on single-cars.php get category link
- in_category for custom post types
- Query multiple taxonomies with pre get posts
- List Posts By Custom Taxonomy
- get_category_link() for custom post type does not include custom slug rewrite?
- How to Display Posts From Category Within a Custom Taxonomy?
- Targeting categories in custom fields
- Can I query posts by taxonomy conditionally based on post type?
- Listing all slugs?
- category list with cutom post count
- Include custom post type custom taxonomies in Categories widget
- Custom Post Type not showing in main loop
- Custom post type categories gives 404 error
- get_terms() parent, child and grandchild
- Get child categories of custom taxonomy category?
- Create query for both custom post type and category
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- Custom post types category
- Custom taxonomy query showing more than 4 posts
- Custom types, taxonomies and query optimization
- Get terms for a specfic post from multiple taxonomies in custom post type
- Can’t pull posts of a Custom Post Type based on the custom taxonomy of the CPT
- Query Custom Post by taxonomy multiple categories
- Retrieve Custom Taxonomies with Description and Slug
- Custom post type specific category box
- Custom Taxonomy Taxonomies of Same Name point to first created URL
- Advanced archive url structure (category, tag and date)
- How to show related posts of category on post within custom posttype
- Check that a slug is present in the get_terms request
- How to set “section categories”?
- Create custom post type categories
- WP_Query for custom taxonomies showing posts from non-specified terms?
- Show Custom Post Type based on Category on Archive Page
- Set a Default CPT taxonomy by taxonomy id
- List all posts associated under custom taxonomy
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- How to manage a dynamic multi-level page hierearchy system?
- Categories manage
- Custom category taxonomy – archive page not showing up
- Help with Travel Guide Setup
- Custom post type category archive URL redirects to home page
- Help with Multi Level Category Archive Page
- Get posts of an specific term of a custom taxonomy
- Query Pulling the same post twice
- Organizing The Custom Post Type with Taxonomies / Parent Posts
- Display 2nd category, only once, as sub-heading, in the loop
- Get a list of categories ids
- Trying to create hierarchy between 3-4 custom post types
- how to limit query_post to first page?
- 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
- 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
- How to add categories to a custom post type using wp_insert_post($new_post);