Home › Forums › General Issues › Display post from the selected post object
Hello,
First of im really sorry if this question was alreay ask, im not really sure if im entering the proper keywords to ask.
Im creating a mall website, each mall braches have a shop and dine list.
1. I have created a post object to a shop/dine to select which mall it is at.
2. I was abale to show the list of malls the shop rents in the single post.
3. What i need now is the vise versa, i need to display the shop info inside the mall single post who only select it.
Example:
1. Nike shop selected mall-1 and mall-2 along with its info like floors and building it is at. (So this will be different information per mall)
2. Nike shop single post can display the list of malls it is at (all good here)
3. Now, when i visit mall-1, i only need to show the information like the floor and building related to that selected mall. No need to display the other mall.
Not that good in coding since im using a page builder(elementor)
Hopefully my explanation and example helps to clear my question.
Also i wish to diplay it via shorcode if possible.
Edit: i think the keyword for this is biderectional
Thank you!
Use a bidirectional relationship on the post object field. Using a bidirectional relationship means the you would do the same thing for the mall post that you did for the shop post.
Hello John, i cant seem to find the bidirectional option im using ACF 6.1, i forgot to mention this is also inside a repeater field.
Hello Pavel, i think it’s okay since im just using the page builder for shortcode. by the way i forgot to mention this is inside a repeater field. Thank you
Bidirectional fields don’t work on sub fields. To do this you would need to build a custom query for elementor to get the posts. And even here I don’t think you can make it work while using a sub field of a repeater.
Thank you John, is there any other workaround for this to happen? without using a repeater?
That depends, why you you using a repeater? can you eliminate the use of the repeater?
There are ways to do this in code, but you are using elementor and you have to use things that work in both elementor and ACF. I actually surprised that you can use a repeater in elementor at all.
Yes, I need to add a repeater to add malls and info about it for that specific mall. like what floor it is located on and which building it is as well.
It’s like this:
1. Mall name
—– Repeater to select the shop/dining: (this should be dynamic since not all malls cater to that shop or dining)
—– Shop 1(using post object selection to pick the shop or dine) – building location – floor
—– Shop 2 – building location – floor
—– Dine 1 – building location – floor
—– Dine 2 – building location – floor
Thank you.
Given the information provided, if I was building something like this I would not be using a repeater to list all of the shops in a mall. I would:
Have a CPT for Malls, each mall would be a different post in this post type
Have a CPT for the stores/shops/whatever you want to call it. Each store would have it’s own post.
There would be a one-to-many bidirectional relationship between the mall and the stores. A post object field on the store post to select the mall and a relationship field on the mall post to select the stores in that mall. I would use my plugin to create this bidirectional relationship because it is beyond what the ACF relationship field can do.
I would have a custom taxonomy for selecting the type of store/shop/whatever
I would have a value in the store to indicate what floor the store is on.
If the same operator can be located in multiple malls I would also have a custom post type for this with a one-to-many relationship between the operator and store post types.
Because you are using Elementor, I would be using Elementor Pro’s theme builder and/or templates to build the templates for showing pages on this site. Using the post widget using a custom query to show the archive pages of of the various post types.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.