custom field value as shortcode parameter

Question

i am using a plugin (download monitor) to display downloads via shortcodes. the shortcode has a single parameter, which is the download’s ID: [download id="123"]

i’d like to be able to modify the download ID parameter within the shortcode via a custom field value.

i’ve created a custom field – ur-single-form-id – and also a shortcode for it [ur_single_form_id] via the following function:

function ur_single_form_id() {
    $cf = get_post_meta( get_the_ID(), 'ur-single-form-id', true );
    $var="<p class="your-class">" . $cf . '</p>';
    return $var;
}
add_shortcode( 'ur_single_form_id', 'ur_single_form_id' )

this was in the hopes of being able to do something like this: [download id="[ur_single_form_id]"]

unfortunately things aren’t parsed as expected, and i get an error saying “download not found”.

how can i implement this such that the download ID is populated within the download monitor shortcode using the custom field value?

thanks

0
vulgarbulgar 1 month 2021-05-05T12:43:56-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse