Site logo

Archived topic

PDF link required

5 replies · Started by David on July 11, 2021

Viewing posts 1–6 of 6

Hi everyone,

I asked this similar question a while ago, and need to come back to it now, so thought a new topic might be best.

I have created Custom Fields (ACF), and have a field called pdf of type file

I have tried every way I can think of to make it a link in an element that display the fields, but just can't make the pdf link work
(button or text link I'm not fussy)

If anyone has any thoughts I'd appreciate any feedback...

Best regards, Dave
ps - I'll post on a couple of FB groups too and post back if I get any useful info!

Hi David,

Can you link us to a sample page you're trying to apply this on? Perhaps inspecting it will give us clues as to why it isn't working.

Also, can you explain a bit more on how the link should work? Is it a download link?

Can you also do a var_dump of the ACF to see if it actually has any output? Perhaps its not returning any value. :D

Thanks Elvin,
I will certainly get back to you with those details.
Dave

Thanks Elvin,
I will certainly get back to you with those details.
Dave

If you can put up a staging site clone and let us have temporary backend access, we can help you check things out.

Let us know. :D

Sorry for delay, coming back to this...
Below is the code I used to solve this if anyone else needs similar assistance.
I used a plugin called XYZ PHP code which creates a shortcode from the added PHP.
pdf is the name of the field in ACF

HTH, Dave

<?php
$file = get_field('pdf');
if( $file ): ?>
    <a href="<?php echo $file['url']; ?>"><?php echo("<button class='button'>Download or View PDF Brochure</button>"); ?></a>
<?php endif; ?>

Nice one. Thanks for sharing it with us. :D

This archived topic is closed to new replies.