Home › Forums › ACF PRO › Relationship field in a block › Reply To: Relationship field in a block
@trenbania So if I’m understanding you correctly you are trying to retrieve field values in a block…from a block on a different page? If that is the case then I have no idea how to do that.
Normally when I use the relationship field its retrieving posts from a specific post type. On CPT’s I don’t use Gutenberg, I just create the acf fields that are assigned to the cpt, not a block. Then the code we were discussing would work. But my CPT’s are very standardized and don’t have the need for arbitrary content via blocks. I have never had to retrieve values in a block from another block on a different page.
You may be able to use
get_post_meta() but since I have never tried that with ACF I’m not sure exactly how that will work, or if it will work at all. Here is a forum topic I found real quick that might help you. https://support.advancedcustomfields.com/forums/topic/want-to-use-get_post_meta-instead-of-get_field-for-array/ You might need to also do a check to see if the block exists using
Sorry couldn’t be more help man.
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!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.