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!
January 12, 2023 03:20:30
E2Pdf
Topics: 7
Messages: 3614
Support
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?
January 12, 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.
January 12, 2023 04:06:57
E2Pdf
Topics: 7
Messages: 3614
Support
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].
January 12, 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) {
Our monthly newsletter keeps you in the loop, so you'll always be up to date with the latest news and updates about E2Pdf.
All trademarks, service marks, trade names, product names, and logos appearing on this website are the property of their respective owners. The use of trademarks such as Formidable Forms®, Forminator Forms®, Gravity Forms®, JetFormBuilder®, WordPress®, WooCommerce®, WPForms® and others is solely for identification purposes (nominative use) and does not imply any affiliation, sponsorship, or endorsement by the respective trademark holders.
We use cookies to collect and analyse information on site performance and usage, to provide social media features and to enhance and customise content and advertisements.
By clicking "Accept Selected", you consent to use of selected cookies according to our
Cookie Policy.