Pass value to a shortcode

February 17, 2023 01:40:10
MariusParaschiv
Topics: 2
Messages: 3
Hello,

I am trying to get some post meta so I created a custom shortcode to pass the ID of a CPT.

I am using [tour_include id="[e2pdf-wc-product key="_st_booking_id" meta="true" index="0"]"] [/tour_include] , but it dosen't work

Is there any way to pass values to shortcode?

Thanks!
February 17, 2023 08:46:08
E2Pdf
Topics: 7
Messages: 3617
Support
Hi,

Unfortunately, WordPress doesn't support such shortcode constructions. It will be easier to modify just the shortcode output via filter:

1st solution:

Shortcode must be changed to:
[e2pdf-wc-product key="_st_booking_id" meta="true" index="0" tour="true"]

Filter to change output:
https://codeshare.io/WdRy7E

Or if you still need it inside the shortcode, 2nd solution:

Shortcode must be changed to:
[tour_include][e2pdf-wc-product key="_st_booking_id" meta="true" index="0"][/tour_include]

Function to add tour_include to process nested shortcodes as:
https://codeshare.io/AdRM6x

The shortcode function must be changed to "nested" shortcode as:
function myshortcode($atts = array(), $value = '')
* where $value will be the _st_booking_id

We remain at your service.

We would really appreciate your feedback at WordPress.org!
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.