Home › Forums › General Issues › Connect a Product page with CPT using Post Object › Reply To: Connect a Product page with CPT using Post Object
You need to make your field “bidirectional”, in other words, there would be a relationship post on the product page that relates the product to all the posts where it is related using the post object field on the CPT. This would likely mean updating every post. There is an explanation of doing this here https://www.advancedcustomfields.com/resources/bidirectional-relationships/ and there are exiting plugins that will make relationship and post object fields bidirectional https://www.google.com/search?q=acf+budirections+relationship
If the prospect of updating every post does not appeal to you then you’ll need to do a reverse relationship query when showing the product. Basically, you need to do a WP_Query()
looking for any posts that have the product ID set in the field for the CPT.
In either of the above cases you’ll need to edit the WooCommerce templates or create filters to show the information on the product page. https://www.advancedcustomfields.com/resources/how-to-get-values-from-another-post/
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.