php – Display ACF on Shop page

Question

I need to display a value using ACF on my WooCommerce Shop/Product Archive page. I tried adding <h2><?php the_field('title'); ?></h2> to archive-product.php, but this did not show.
Then tried adding to functions.php, but also this did not display in my shop page.

function show_title() {
global $product;
$id = $product->get_id();
$title = get_field('title',$id);
if ( $title ) { 
    echo '<span>'.$title.'</span>';
}
}
add_action('woocommerce_after_shop_loop_item_title', 'show_title', 3 );

0
P.Sav 5 months 2021-05-21T22:31:28-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse