Home Forums Front-end Issues Displaying A button to Download a PDF (File)


Displaying A button to Download a PDF (File)

  • Hello there!

    I’ve been digging around for 2 days and I still didn’t solve this problem:

    As I’m creating an online catalog, I would like to dispay a button on each product page that’s linked to their unique PDF file (Datasheet) that I can define in backend with the File Field Type.

    Everything is going as planned, Here’s a look at the “setup”:

    ACF Setup

    but no matter how I pass the request, I always get a wrong HTML link like so:

    Here’s the code to retrieve the File Field Type

    <?php if( get_field('fiche_pdf') ): 
    $link= the_field('fiche_pdf');?>
              <a href="<?php echo $link;  ?>" target="_blank"><strong>Brochure</strong></a>

    Here’s the result


    I’ve tried with a Link field type, same result:

    Here’s the Code (as simple as possible):

    <a href="<?php echo esc_url($link); ?>">click here</a>

    And the result:


    I think that it’s related to the fact that I can’t execute php, because the code work if I use XYZ PHP CODE (Php shortcode plugin)

    Truly, the best goal for me is to be able to pass the url to an Advanced button (from WPBakery’s Mega Addons)

    But this is another problem…

    You can take a look at this here:

    Thank you for your help 🙂

    $link= get_field('fiche_pdf');

    the_field() echos the value, get_field() gets the value. They cannot be user interchangeably.

    As far as the plugin and why it’s butchering it, I don’t know.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.