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 has_block()
https://developer.wordpress.org/reference/functions/has_block/
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!
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.