Switched from Builder to Code and Now Relationship Doesn't Show
Support › MB Relationships › Switched from Builder to Code and Now Relationship Doesn't ShowResolved
- This topic has 6 replies, 2 voices, and was last updated 1 year, 9 months ago by
Michael Kern.
-
AuthorPosts
-
July 15, 2023 at 10:08 AM #42579
Michael Kern
ParticipantHello all,
I made a relationship in the builder linking a "Services" CPT to a "Therapists" CPT. Then I decided to add taxonomy to the Services CPT and realized I couldn't use query vars to go that deep in the builder. So I switched to PHP code to make the relationship with taxonomy query vars, but I kept the ID of the relationship the same, and deleted the one I initially made in the Builder.
Now, the relationship doesn't show on the Therapist Edit screens unless I rename the ID of the relationship. How can I find the entries of the old Builder-relationship so I can delete it so that the code version takes over and shows in the edit screen?
I hope I'm making sense.
July 15, 2023 at 10:40 AM #42580Michael Kern
ParticipantBetter yet, is there a way to make taxonomy query vars in the builder without it parsing the information in PHP with slashes?
July 15, 2023 at 3:53 PM #42585Peter
ModeratorHello,
You can find the relationship in the builder by going to Meta Box > Relationships. Or find the item in the table
wp_posts
with post typemb-relationship
.Regarding your second question, what is the taxonomy query vars in your case?
July 15, 2023 at 9:43 PM #42589Michael Kern
ParticipantSure. What I'm trying to achieve is related to the support you provided here. Except instead of doing it via PHP code, I want to use the tax_query array inside the Builder UI.
However, when I try to put an array inside of the Query Vars field in the Relationships Builder UI, it "sanitizes" the array with slashes, likely to escape the characters being used. I do not want it to sanitize. Unfortunately, there's no sanitization customization in Relationship Builder UI. So I must resort to registering the relationship via PHP code.
Here's what I'm putting in the builder:
https://imgur.com/a/f9xrQzXHere's the output:
'field' => [ 'query_args' => [ 'tax_query' => '[ \'taxonomy\' => \'service-types\', \'field\' => \'slug\', \'terms\' => \'concentrations\' ]', ],
The problem I am experiencing with this is compatibility with another plugin, Admin Columns Pro. When registering relationships via PHP code, ACP doesn't integrate the relationship properly and therefore does not provide capabilities to do inline editing via an admin column. When doing it via the MB Builder UI, it does, which is why I want the Builder to stop sanitizing my Query Vars in this relationship.
July 15, 2023 at 9:43 PM #42590Michael Kern
Participantignore the <div> tags btw
July 17, 2023 at 6:06 PM #42600Peter
ModeratorHello,
In the builder, you can use the dot notation or JSON notation to pass an array to query args. Read more in the documentation https://docs.metabox.io/extensions/meta-box-builder/#dot-notation
July 17, 2023 at 6:33 PM #42601Michael Kern
ParticipantThank you so much! I looked everywhere for something like this. Clearly I didn't look hard enough. Thanks again!!!
-
AuthorPosts
- You must be logged in to reply to this topic.