Relationships variables?
Support › MB Relationships › Relationships variables?
- This topic has 3 replies, 2 voices, and was last updated 4 years, 2 months ago by
Long Nguyen.
-
AuthorPosts
-
August 4, 2021 at 2:32 AM #29875
[email protected]
ParticipantMaybe my challenge can be easily solved with other methods, but is it possible to have parameters (custom fields) on a relationship instance?
The challenge: two CPT (authors and publications). I'd like to give the authors the ability to handpick a couple of "publications highlights" that will be featured on their personal "frontend Single Page".
The challenge here is that a publication will have several authors, and it may be a "highlight" for some of its authors but not all.Hence, I imagined that the relationship between an author and a publication would have the "highlight" custom field. Is this possible?
Or would it be better to have a custom field on the user that would allow to search internally for a given publication and insert its ID into that user repeatable custom field?
Thank you for your expertise.
August 4, 2021 at 10:33 AM #29880Long Nguyen
ModeratorHi,
I think you can create a custom taxonomy
highlightfor each CPT. Using the custom taxonomy will get posts faster than the custom field, please read more here.Then you can use the setting
query_argswhen creating the relationship to show thehighlightposts on the select box only.
Get more details on the documentation https://docs.metabox.io/extensions/mb-relationships/#syntaxAugust 5, 2021 at 12:47 AM #29890[email protected]
ParticipantHi Long. Thank you for the suggestion. I have a question regarding your suggestion.
Then you can use the setting query_args when creating the relationship to show the highlight posts on the select box only.
This would require first to add the term "highlight" to the publication that the user wants to target (to appear on the select box), and then add the relationship in the user profile, right?
It would also require two relationships between the users and CPT publications right? One that is a "normal" relationship, and another one that is the "highlighted" relationship as you described.
Hope I'm not doing any big confusion here.
August 5, 2021 at 12:44 PM #29912Long Nguyen
ModeratorHi,
We need only one relationship between Author and Publication.
- Assign some publication posts to the term
highlight - Use the setting
query_argswhen creating the relationship to show the publications that have the termhighlighton the select box.
- Assign some publication posts to the term
-
AuthorPosts
- You must be logged in to reply to this topic.