I have parents (establishments), parents (brands) and children (cocktails).
Obviously, an establishment can have many cocktails. A brand of spirit can also have many cocktails made with this brand.
BUT I just found out that a cocktail can be made with 2 ingredients (brands)
So a children can now have 2 parents.
- Is there a way to do this? What can I change in my actual setup to be able to choose 2 parents in a coctkail post ?
- Or do I have to enter a cocktail 2 times ? I don't mind BUT I cannot have the same URL twice, so... What to do ?
I also have custom searches. I would like cocktail-A to come out when searching for brand A, but also come out when searching for brand B (if it is a children of both brands).
And then, to add to the trouble...
I just learned that an establishment can have 2 locations/franchises. BUT they will offer the same cocktails. So a cocktail (children) could belong to 2 parents (establishment-A and establishment-B).
Again, is there a way to do that with minimizing the work of redoing all my views, layouts, etc.
I am now live, so...
hidden link
So I viewed the many-to-many tutorial. This would work in my situation.
However, it would imply going into 250 posts and assigning them one by one, redoing a dozen of views, etc. In fact, this would be better done when building the website from scratch. Adding it after is a pain.
But I found a workaround: posting it here in case it helps someone.
I assigned all cocktails belonging to Bar-A and Bar-B to Bar-A. Then, I created a view that shows all cocktail from Bar-A. I put this view in the Bar-B page. That's it!
You need to show Post content in your layout, below the view that shows cocktails. But you will get a "Nothing found" message for Bar-B, above the view with all cocktails. Just erase the line in the cocktails view where the condition says show message nothing found if empty.
============
Now I have a follow up question.
In the same vein, I will create a view with all cocktails that are also part of brand-F
But I want to put this conditionnaly in individual brand page, as such:
IF brand is brand-F > show view that as all cocktails from brand-F
else > show normal view for brands
Can this be done ?
Dear Mylene,
For the question:
IF brand is brand-F > show view that as all cocktails from brand-F
else > show normal view for brands
I suggest you try with Views shortcode [wpv-conditional], to check if current post ID([wpv-post-id]) is the specific ID(brand-F), then display the specific content(view that as all cocktails from brand-F), or display other content. see our document:
https://toolset.com/documentation/views-shortcodes/#wpv-conditional
https://toolset.com/documentation/views-shortcodes/#wpv-post-id