Relationship Field Post Data

6 November, 2021 16:26:08
marissaezell
Topics: 1
Messages: 2
I have used the above to be able to output the post-title of the relationship field post, but how do I out put the ACF fields for that post?

For example

I have a custom post type called Physicians and one called Sites.

Physicians has ACF fields for Email and Phone.

Sites has a ACF relationship field to associate the Physicians to that post.

So I was able to get the Physician post title (their name) but I don't know how to now get the email and phone from that related post.

Help please!
7 November, 2021 00:40:57
E2Pdf
Support
Topics: 7
Messages: 3163
Hi,

E2Pdf has extended feature for getting relation post data but it's not yet documented as this is new feature and it's still under "testing" stage.

Here is the explanation with examples for getting related post data. It's need to add id="dynamic", close shortcode and use shortcode which will get Post ID inside. You will need to remove "filters" added to functions.php:

[e2pdf-wp id="dynamic" key="post_title"][e2pdf-wp key="custom_posts" meta="true"][/e2pdf-wp] - It will get post title for Post ID which is rendered by inner shortcode [e2pdf-wp key="custom_posts" meta="true"] (You must get exactly the Post ID).

If you have field where you can assign multiple related Post IDs, then it's saved as array and you need to use "path" attribute to navigate through this array to get only 1 needed Post ID and the construction will look like this:

[e2pdf-wp id="dynamic" key="post_title"][e2pdf-wp key="custom_posts" meta="true" path="0"][/e2pdf-wp] - it will get post title for 1st Related Post ID.

[e2pdf-wp id="dynamic" key="post_title"][e2pdf-wp key="custom_posts" meta="true" path="1"][/e2pdf-wp] - it will get post title for 2nd added Related Post ID.

and so on...

* [e2pdf-wp id="dynamic" key="post_title"] - can be replaced with any other shortcode related to "e2pdf-wp" like getting meta value, for example:

[e2pdf-wp id="dynamic" key="address" meta="true"][e2pdf-wp key="custom_posts" meta="true"][/e2pdf-wp] - where "address" is the post meta key which you need to get.

P.S. The only limitation of using such shortcodes that if you will need to use multiple "e2pdf-wp" shortcodes in one element, all they must be closed as:

[e2pdf-wp id="dynamic" key="post_title"][e2pdf-wp key="custom_posts" meta="true" path="0"][/e2pdf-wp]: [e2pdf-wp key="post_title"] - INCORRECT.

[e2pdf-wp id="dynamic" key="post_title"][e2pdf-wp key="custom_posts" meta="true" path="0"][/e2pdf-wp]: [e2pdf-wp key="post_title"][/e2pdf-wp] - CORRECT

If you will have problem with setup above solution, you can attach some screenshots with your ACF field settings (key and return format) for "Relation Post ID" field (for parent post), "Email" and "Phone" fields (for related posts).

We remain at your service.
We would really appreciate your feedback at WordPress.org!
7 November, 2021 10:03:10
marissaezell
Topics: 1
Messages: 2
Thank you so much!!!!!!
This is an amazing plugin. We are buying the license and will be sure to leave a fabulous review!