Hey all,
I noticed that the native Bricks query loop option generated by Metabox works both ways (e.g. works on both the TO and FROM CPT templates).
However, when I use a custom query, I need to make two WP_Queries: one for TO and one for FROM, and these would appear as two separate queries in the Bricks Builder Query Loop dropdown.
What I am trying to achieve is a single option in the Bricks Builder Query Loop Dropdown that queries the relationship both ways in the same exact manner that the default Metabox-generated query does.
Is there code somewhere that shows what the default query looks like so I can apply the same code to my custom WP_Queries so I can use them with one option in the builder instead of two separate options?
Hope this makes sense.
Hey Michael,
why do you want to recreate something that is already there? 
In the end you have to have a look at the Meta Box documentation about relationships. And if you want to make it work “automatically” in both directions you have to probably precede the code with a check on what kind of template you are.
So imagine having an employee ↔ service relationship. If you’re on an a single employee page – is_singular( 'employee' )
– you wanna set the from
parameter. If you’re on a single service page – is_singular( 'service' )
– you wanna set the to
parameter.
Best,
André
why do you want to recreate something that is already there? 
Because its perfectly working code in both directions already, but I want to turn it into a snippet that I can customize over and over again in WPCodeBox with WP queries. Why come up with my own work around when the builder already generated a code that if I find it, I can repurpose it as a bunch of snippets? I just want something that can work on both directions and be used on either template that I want without having to create separate bricks filters for each direction of the query.
In the end you have to have a look at the Meta Box documentation about relationships. And if you want to make it work “automatically” in both directions you have to probably precede the code with a check on what kind of template you are.
I did look at the metabox documentation about relationships (and there is fantastic WP query code for going both directions and customizing), but when I asked how every single meta box generated relationship automatically ends up in the bricks builder drop down working both ways, they told me to consult with the bricks builder team.
However, I’m not knowledgeable in PHP or the bricks developer resources. The stuff looks like French to me. Brickslabs created tutorials with snippets on how to insert WP queries related to meta box relationships into bricks builder. However, when I do it that way, I have to add a new option to the drop down for each direction of the WP query, instead of having one that just works out of the box bi-directionally. Looking for most efficient and clutter-free solution.
Of course, this is my own lack of PHP knowledge at work here. I don’t have time to “learn it in a jiffy” in this case. Need something real quick if possible. That’s why I’m asking the forum.
This whole effort is to avoid clutter in the drop down query loop menu. I just want one option in the query loop drop down that works both TO to FROM and FROM to TO no matter which template I’m using it on.