Insert variable in shortcode

Formidable Forms
February 27, 2022 19:00:06
NTR
Topics: 2
Messages: 3
I'm trying to run a shortcode in my theme's single post page (single.php). Trying to set the dataset parameter to an entry ID which is stored in a post custom field. Following is my code:

<?php
$form_id = get_post_meta($post->ID, 'entry_ID' , true);
echo do_shortcode('[e2pdf-download id="3" button-title="Download the Proposal" dataset="' . $form_id . '"]');
?>

However, this is not working. The shortcode does work when I use a static entry ID number rather than the $form_id variable for dataset. Any suggestion how to get dataset variable to work?
February 27, 2022 23:19:12
E2Pdf
Topics: 7
Messages: 3617
Support
Hi,

The shortcode looks okay however are you sure that form_id returns correct Entry ID and not Form ID? Can you check please with.

Can you check please which value you get via var_dump? as:

$form_id = get_post_meta($post->ID, 'entry_ID' , true);
var_dump($form_id);
die();


We would really appreciate your feedback at WordPress.org!
February 28, 2022 07:08:00
NTR
Topics: 2
Messages: 3
The Entry ID stored in the variable was correct. However, I somehow missed in the shortcode that it should be id=2 rather than id=3. Was using the wrong pdf. It now displays the download link correctly in my theme. Thank you for your assistance! Excellent product.
Get News and Updates
Our monthly newsletter keeps you in the loop, so you'll always be up to date with the latest news and updates about E2Pdf.
* You can update your email subscription preferences here.
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.
© 2017 - 2026, https://e2pdf.com

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.