Home › Forums › Front-end Issues › Show ACF field in WooCommerce Archive Listing › Reply To: Show ACF field in WooCommerce Archive Listing
Thanks very much for your help. Your explanation helped me to understand how hooks work.
It’s actually on the archive page I want to add the ACF so in content-product.php using ‘woocommerce_after_shop_loop_item_title’ should have worked, but my theme (Astra) also seems to be influencing that area, so in the end I hid the title using the theme customiser and then in functions.php
/**
* ADD THE ACF DESCRIPTOR BY REMOVING THE FUNCTION AND REPLACING IT WITH OUR OWN - YOU MUST ALSO HIDE THE TITLE IN ASTRA CUSTOMISER
*/
function sly_switch_loop_title(){
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'sly_template_loop_product_title', 15 );
}
add_action( 'woocommerce_before_shop_loop_item', 'sly_switch_loop_title' );
function sly_template_loop_product_title() {
echo '<h4 class="sly-custom-shop-list-title">' . get_the_title() . '</h4>';
echo get_field( 'descriptor' );
}
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.