Home › Forums › Front-end Issues › How do i display custom fields using Function.php › Reply To: How do i display custom fields using Function.php
I think what you need to do is find the hook where you want these things displayed, have a look here:
https://businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/
I think the closest hook is woocommerce_before_add_to_cart_form.
Try this in your functions.php file:
add_action('woocommerce_before_add_to_cart_form', 'display_product_fields' );
function display_product_fields() {
$fields = get_field_objects();
if( $fields ): ?>
<ul>
<?php foreach( $fields as $field ): ?>
<li><?php echo $field['label']; ?>: <?php echo $field['value']; ?></li>
<?php endforeach; ?>
</ul>
<?php endif;
}?>
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.