Home › Forums › General Issues › Add ACF field of single product page › Reply To: Add ACF field of single product page
Hi @danis44
You can try something like:
add_action( 'woocommerce_before_add_to_cart_form', 'my_pdf_field' );
function my_pdf_field() {
$pdf = get_field( 'pdf' );
#if we have data, show it
if( $pdf ){
echo '<a href="'.$pdf['url'].'">link</a>';
}
}
I’ve assumed the PDF field you’ve added is called pdf, it’s a file type and returns an array (not a URL)
Code is untested and goes in your functions.php file
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.