Support › MB Relationships › Display Relationship Field On Specific Category
Hi. I want to display the relationship I created on specific category only. I don't want to show it to all posts. Is it possible?
Yes, it is possible. You can use the setting query_args to filter posts to select in the list. Please read more on the documentation https://docs.metabox.io/extensions/mb-relationships/#using-code
and refer to this topic https://support.metabox.io/topic/help-needed-for-using-query-args-at-relationships/
Hi Long. I tried adding this on query args but it still shows on other categories.
Kindly refer to the screenshot above.
The query args misses the parameter terms
'query_args' => [
'tax_query' => [
'taxonomy' => 'category',
'field' => 'slug',
'terms' => 'technology',
Please check the documentation again https://docs.metabox.io/extensions/meta-box-builder/#dot-notation
Hi Long, i dont get it. what should I put if i only want to show it on post that has category of Expert Tips?
It's not possible to use the builder to get all posts of a category (all terms). If you want to use the code, you have to get all terms of a category to pass to the tax_query. Please refer to this topic https://stackoverflow.com/questions/47064244/how-to-display-a-list-of-posts-from-a-taxonomy-term-in-wordpress