Home › Forums › General Issues › How can I display a specific field value from a linked(relationship/object)post? › Reply To: How can I display a specific field value from a linked(relationship/object)post?
Are you saying that, given your example, in the Edit Product screen for “Product 1” there would be a field with the text “Open”? And this field is set to the company_status field of an associated company?
If that’s the case, I would do something like this:
1. Associate Products to Companies (already done).
2. Create a “company_status” field on Company cusotm post type.
3. Create a “product_company_status” field on Product custom post types.
4. Use the update_value hook to detect the Company’s company_status field getting updated. See the Update_value() documentation.
5. In the hook function, find all products that are associated with that company. Then loop over all Products and update the “product_company_status” field with the new “company_status”. See the update_field() documentation.
Now whenever a “Company” post’s has it’s company_status value updated, the hook function will fire, updating all products. I hope that makes sense.
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!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.