$term
isn’t being set anywhere in your code. You’re putting IDs into $terms_ids
, but then in your query you’re using $term->term_id
. $term
doesn’t exist outside of the foreach
. You need to be passing $terms_ids
directly into terms
:
$terms = get_the_terms( get_the_ID(), 'kosmetyki_dystrybutor');
$terms_ids = [];
foreach ( $terms as $term ) {
$terms_ids[] = $term->term_id;
}
$args = array(
'post_type' => 'kosmetyki',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'kosmetyki_dystrybutor',
'field' => 'term_id',
'terms' => $terms_ids,
)
),
);
$query = new WP_Query($args);
Related Posts:
- Get Posts Under Custom Taxonomy
- Displaying the category name of a custom post type
- Show WordPress Custom Taxonomy Items Based On a Selected Item From Another Custom Taxonomy
- Adding Multiple Values to a Post Meta Key
- How do I get the slug of a custom taxonomy category of a post?
- How can I add a meta-box to the posts editor containing all items of a custom taxonomy as checkbox?
- Get posts by name and taxonomy term
- Choose whether to automatically add a taxonomy with the same name as the post
- Get Posts Under Custom Taxonomy
- How to associate a custom taxonomy to a post multiple times
- Customizing URL slugs of Custom Post Type and Taxonomy make posts/pages 404
- How to get post count including nested categories
- Custom Taxonomy From Database
- Multiple loops on a Search result page?
- Different post sort order within different categories
- Elegant way to include only published posts with get_objects_in_term()?
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- How are terms connected with posts in database?
- Convert IPTC keywords to blog post tags
- Create new category upon save based on post information
- Show Custom Taxonomy Categories, Listing of Posts, and Single Post via AJAX
- meta_box or custom_field as a second tinymce post-instance?
- Importing data from spreadsheet into wordpress DB, along with custom taxonomies and their terms
- Custom Taxonomies Incorrectly Counting Revisions?
- wp_update_term is always launched after wp_insert_term
- Display taxonomy term only if there’s a value
- deleting terms programmatically
- How to display different single post template based on author?
- Post taxonomy from exif data
- Remove custom posts that match taxonomy value
- Using Custom Posts with Metaboxes and Drop-downs
- Does an action fire when adding a tag via the “Tags” meta box?
- wp query with dynamic taxonomies and terms?
- disable column on post and user list
- Get Posts via Taxonomy Term Name with Space
- Why won’t my taxonomy query show up?
- How to set up multiple taxonomies for groups of posts
- Sidebar links for different pages
- Automatically Updating Publish Date Bug
- Preserve term order per post in a non-hierarchical taxonomy
- Get posts of ONE taxonomy term of custom post type
- Pass data between pages
- Display tag image in post using Taxonomy Images plugin index.php
- wp_get_object_terms returns only Uncategorized on first publish
- How to insert 2 args into 1 Wp_Query for a slideshow
- Help with Taxonomies
- Force the “Choose from the most used tags” meta box section to always be expanded
- How to Restrict Previous & Next Post Link to Posts of Same Category?
- Prepending %category% onto default posts fails
- get_adjacent_post by language
- Duplicate Custom Post Type and Taxonomy Slug
- How to render taxonomy in loop of custom post_type
- Remove Custom Post Type Slug and add Custom Taxonomy to Permalink Structure?
- How can I setup a relationship using categories in WordPress?
- How to display posts via custom taxonomy terms using checkboxes?
- How to allow visitors to filter posts by multiple taxonomies
- How to add tags (custom taxonomy) to post class css?
- How can I hide tags on a child-category page, if that tag has not been used?
- 404 error on default post type and default taxonomy fronted page
- Saving custom fields to a custom taxonomy
- How to get Tags with specific post id
- outputting posts’ taxonomies: cant get ‘get_the_taxonomies’ working
- Copy taxonomy terms from one post to another programmatically
- Loop parent terms {display posts} AND loop child terms {display posts}
- Displaying posts that belong to a specific author
- Variable not working in WP_Query
- relating business and products with custom taxonomy?
- Is there a query string for edit.php to show all posts that have no custom taxonomy terms?
- Form to post new post with custom taxonomies
- WordPress bulk category select when publishing post
- How to show a custom taxonomy in the theme?
- Check if current user has a post and that post has any term/s from a specific custom taxonomy outside the loop
- Unable to differentiate between two categories under custom post type on single.php
- Copy/Move selected taxonomy terms to another taxonomy for posts
- Limiting post list by taxonomy
- How To Use Custom Tax of a Post Type
- How to output all taxonomy links from a custom post type in a menu?
- Geting error in post and category [closed]
- Custom post type and taxonomy page templates
- How to display the post categories for each post inside the loop with custom format?
- WP query taxonomy optimization
- Query to fetch custom taxonomy along with post title
- Define multiple prefixes for custom post type
- Post not using taxonomy template
- Show post count in custom taxonomy page
- Create/Set Category as Title of Post
- How to manage a dynamic multi-level page hierearchy system?
- Page with Category Returning 1
- how let users select categories for posts in frontend?
- If taxonomy has more than 6 posts, display show all
- filter buddypress users posts by user ‘xprofile’ custom fields
- wordpress display posts by terms id or name
- My custom query is displaying random posts in random order
- Multiple Custom Post Type loop logic
- How to list all names and descriptions of a custom taxonomy
- How to display term in archive page?
- How to get all the terms of a post
- Special Query: Title, Terms, Content – %LIKE%
- retrieve post slug by post_tags taxonomy
- Filter/Sort Post Form On Taxonomy page