Download Shortcode
Forcing download in another way? (3 posts)

  1. J
    Posted 3 years ago #


    I am trying to use this plugin in a slightly different way and perhaps you'd know if and how I can do it.

    I am using a php widget (a widget that allows php) because I need to pull the file name dynamically with this code:

    <?php the_field('downloadable_material'); ?>

    This widget does not allow shortcodes for some reason, but if I use the do_shortcode php line, i can't seem to insert the php code above inside the shortcode that is inside the do_shortcode php.

    Which would end up something like this:

    <?php echo do_shortcode('[download]<?php the_field('downloadable_material'); ?>[/download]'); ?>

    which obviously doesn't work.

    I am also unable to use the wp-content/force-download.php?file= inside the middle of the link because it pulls the full url as is from the php code the_field I mentioned.

    Any other suggestions?



  2. Drew Jaynes
    Docs Czar
    Plugin Author

    Posted 3 years ago #

    The shortcode relies on the ability to take the URL (relative to /wp-content/), split and rejoin it to form the forced-download link. Out of the box, what you're trying to do probably isn't possible.

    Can you provide an example for what the_field( 'downloadable_material' ); might return?

  3. J
    Posted 3 years ago #

    It will return the full file url, like:


    Thanks for trying to help

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic


No tags yet.