I have an ACF repeater field containing a relationship field and an image field.
I am able to display the image using an image template object with the value:
[acf field='artworks_0_custom_image_url' post_id="[id]"]
----
I am able to display the post content of the first relationship field item using a HTML template object with the value:
[e2pdf-wp key="artworks_0_artwork" meta="true" path="0"]
and the filter:
function e2pdf_extension_render_artwork_values( $value, $element_id, $template_id, $item, $dataset )
{
if ($value && $template_id == '1') {
I have also tried using this value directly in the image object:
[e2pdf-wp key="artworks_0_artwork" meta="true" path="0" attachment_image_url="true" size="full"]
Can you advise how I can show the feature image of the relationship field that is inside the ACF repeater object?
Thank you!
12 January, 2023 03:20:30
E2Pdf
Support
Topics: 7
Messages: 3330
Hi,
Can you please create 2 "textarea" inside E2Pdf Template and use separate shortcodes:
[acf field="artworks_0_artwork" post_id="[id]"]
[e2pdf-wp key="artworks_0_artwork" meta="true"]
Is any of these shortcodes output just the related Post ID? We would really appreciate your feedback at WordPress.org!
12 January, 2023 03:52:54
natacha
Topics: 2
Messages: 8
This one: [acf field='artworks_0_artwork' post_id="[id]"]
generates the error:
Fatal error: Uncaught Error: Object of class WP_Post could not be converted to string in \wp-content\plugins\advanced-custom-fields-pro\includes\api\api-template.php on line 902
I assume because the returning value is not a String.
This one: [e2pdf-wp key="artworks_0_artwork" meta="true"]
displays in the textarea: a:1:{i:0;s:5:"26828";}
----
The above got me thinking - Something else I tried...
Using this:
[e2pdf-wp key="artworks_0_artwork" meta="true" path="0"]
as the value in an image object displays the correct relationship field ID as the image.
But if I use a filter to try and reference this ID value:
function e2pdf_extension_render_artwork_values( $value, $element_id, $template_id, $item, $dataset ) {
It must output the URL to Post Thumbnail. If it will work, just move this shortcode to the "Image" object and remove any PHP filters added to the "Image" object.
We would really appreciate your feedback at WordPress.org!
12 January, 2023 04:06:57
E2Pdf
Support
Topics: 7
Messages: 3330
If it will work, you can also replace the shortcode for the Post Content and avoid using PHP filters:
P.S. Keep in mind please that if in the same "html" / "field", where such shortcode will be placed, will have any other [e2pdf-wp] shortcodes, it must be closed as [e2pdf-wp key="post_content"][/e2pdf-wp].
We would really appreciate your feedback at WordPress.org!
12 January, 2023 04:29:38
natacha
Topics: 2
Messages: 8
That worked!
BUT can you confirm if using dynamic shortcodes like this prevents the filters from working?
Since now my post_content filter no longer works. The reason I am using a filter on the post_content is that I concatenate extra ACF group field values, and number formatting:
if ($element_id == '10') { //Artwork text description
//Show Artwork field post title field & price (if any)
$related_post = get_post($value, ARRAY_A);
if ($related_post) {
and your content shortcode must be modified to (added pricing_details="true"):
[e2pdf-wp id="dynamic" key="post_content" pricing_details="true"][e2pdf-wp key="artworks_0_artwork" meta="true" path="0"][/e2pdf-wp]
We would really appreciate your feedback at WordPress.org!
12 January, 2023 07:53:56
natacha
Topics: 2
Messages: 8
I can confirm that everything is working perfect! I learnt a lot of advanced E2PDF / advanced ACF field integrations from your code responses above.
I hope this helps others too. I learnt E2PDF by reading through other people's questions, hence this post should hopefully help others also!
We use tools, such as cookies, to enable essential services and functionality on our site and to collect data on how visitors interact with our site, products and services. By accepting cookies you are agreeing to our Cookie Policy.