Support

Account

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' );
    }