• Hi. I am using the “More Fields” plugin to capture specific user input information. In this case the users puts in a soundcloud shortcode, which I then want to display and execute in a footer widget using php. I figured out how to execute php and shortcodes in a widget. However, I am having an issue getting one string that pulls different shortcodes from each user.

    Keep in mind the easiest for my users will be to input the entire shortcode, not just the dynamic element which is the soundcloud generated user number.

    I understand there is a way to use “do_shortcode”.:
    <?php echo do_shortcode('[shortcode]'); ?>

    Code to display the dynamic more field:
    <?php meta('soundcloud_embed'); ?>

    Demo soundcloud shortcode a user would input:
    [soundcloud url="https://api.soundcloud.com/users/157915" params="auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true" width="100%" height="450" iframe="true" /]

    Ultimately, this is what I want to happen, but I am not sure the correct way to write it so that the shortcode is actually executed:
    <?php echo do_shortcode('meta('soundcloud_embed')'); ?>

    I appreciate any knowledge you can download on me. Thanks.

Viewing 1 replies (of 1 total)
  • Thread Starter rajaito

    (@rajaito)

    Whoop! I found the answer to my question.

    This works:

    <?php echo apply_filters('the_content', get_post_meta($post->ID, 'soundcloud_embed', true)); ?>

Viewing 1 replies (of 1 total)
  • The topic ‘How to execute soundcloud shortcode / echo do_shortcode with dynamic variable?’ is closed to new replies.