I’m creating a site in WordPress where some PDFs will be uploaded for users to download. Now I’m struggling a bit with PHP to figure out a way to display two different texts on the download button, depending on wether a PDF has been uploaded yet or not.
The button is currently made this way:
<a href="<?php the_field('presentation_pdf'); ?>" target="_new" class="small round button">Download</a>
What I need help to figure out now is a php-function where it checks if the link is to a PDF-file or not, and display the texts: Download (Link leads to a PDF-file) or “Not yet uploaded” if the link is “empty”.
assuming your pdf is saved as a
postmeta
, you can check if meta exist and then make the conditional: