• Hi I need help with some custom shortcode.

    <?php echo do_shortcode('[download file="readme.txt" title="title"]') ?>

    This is the shortcode that displays an email form which gives a file download when a form is submitted.

    I would like to add an option to add the file dynamicaly.

    <?php $downloadfile = get_post_meta( get_the_ID(), '_staff_dlfile', false ); foreach ( $downloadfile as $att );?> <a href="<?php echo wp_get_attachment_url( $att );?>" target=_blank">Download test file here...</a>

    This is the code that I am using to allow the file to be downloaded.
    But it is always available for download. Is there a way to combine this two code segments to get the one that does the trick?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Not quite making sense. Can you elaborate with examples, urls, screenshots ?

    Thread Starter sasa2209

    (@sasa2209)

    Well I will try to explain because the screenshot or the url is not really relevant here. The function is…

    <?php $downloadfile = get_post_meta( get_the_ID(), '_staff_dlfile', false ); foreach ( $downloadfile as $att );?>
    <a href="<?php echo wp_get_attachment_url( $att );?>" target=_blank">Download test file here...</a>

    This is the function to display meta box value which is set under the custom post type. It is used to upload the file. This way it works fine. I get the file url in a anchor tag with the ability to download the file itself.

    The second…

    <?php echo do_shortcode('[download file="readme.txt" title="title"]') ?>

    This is the shortcode used ot display simple form to collect an email address before the actiall download. So a visitor needs to enter his name and email to get the download link. You can see that there is a dummy namre

    readme.txt

    which obviously will not be used here.

    I need to have that value updated dynamicaly with the value from the meta box. So if a admin uploads the file in the custom post type which has that meta box assigned I want to have that shortcode updated with this file url so ther is no need to manually type in the file name.

    I hope this makes sense.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcode help’ is closed to new replies.