Pass value to a shortcode

17 February, 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!
17 February, 2023 08:46:08
E2Pdf
Support
Topics: 7
Messages: 3345
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!