• Resolved Mackenzie Child

    (@mackenzie-child)


    I am trying to setup the [download] shortcode within my template using the Advanced Custom Fields repeater field.

    If I have a regular shortcode
    <?php echo do_shortcode( "[download label='Download mp3']https://example.com/wordpress/wp-content/uploads/example.mp3[/download]"); ?>

    Everything works fine.

    But if I try to sub in the advanced custom fields, it prints out the url instead of allowing a download.

    <?php echo do_shortcode( "[download]" . the_sub_field('download_link') . "[/download]"); ?>

    Is there something I am doing wrong?

    https://www.ads-software.com/plugins/download-shortcode/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Drew Jaynes

    (@drewapicture)

    Hi Mackenzie,

    First of all, glad you’re finding the plugin useful! A couple of ideas for your problem spring to mind:

    The first is that you should be using get_sub_field() for the download link instead of the_sub_field() since you’re already echoing the do_shortcode() call.

    The second (if adjusting the above doesn’t do it) would be to first ensure that whatever type of URL is retrieved from the custom field is compatible with the download shortcode plugin. That is to say, the file is located relative to the wp-content/uploads path (or whichever path is specific via the ds_download_files_directory filter (default is the uploads path).

    If the outputted URL seems correct, and the download shortcode still isn’t working, would you mind providing a live URL with a sample download link for me to look at?

    Thread Starter Mackenzie Child

    (@mackenzie-child)

    Hah! I was banging my head against the wall for a few hours trying to find a solution and the fix was to simply change the_sub_field() to get_sub_field().

    Thank you so much, Drew!

    Love your plugin, man!

    Plugin Author Drew Jaynes

    (@drewapicture)

    Glad you got it worked out. Feel free to write a review if you have a few minutes, always nice to see what people have to say ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Trying to use 'echo do_shortcode' along side Advanced Custom Fields’ is closed to new replies.