This code below seems to work:
<?php $file = get_field('product_brochure_pdf'); if( $file ): // vars $url = $file['url']; $title = $file['title']; endif; ?> <?php if(get_field('product_brochure') == 'yes') : ?> <a href="<?php echo $url; ?>" title="<?php echo $title; ?>" target="_blank"><?php echo $title; ?></a> <?php else : ?> <?php endif; ?>
Can any of you guys who are more versed in PHP check that out and see if there are any glaring issues? Like I said, it does work, just want to make sure it’s coded correctly.
What it should be doing is if someone chooses ‘Yes’ from the radio button choice (meaning yes, there is a product brochure) it will then show the conditional ‘File’ field called Product Brochure PDF (to allow someone to upload a PDF). The code will output the link to the PDF along with the title of the PDF.
If someone selects ‘NO’ on the radio button choice, it simply won’t display anything on the front end.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Sorry for the issues with ACF's API SSL certificate this morning. We've resolved it and your activations and downloads should be back to normal again. Thanks! ^LG— Advanced Custom Fields (@wp_acf) November 2, 2022
© 2022 Advanced Custom Fields.