Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Woocommerce – add an attribute above the title

  • Hi Team,

    This may be OOS..

    On the product archive, I try to add an attribute above the title (‘Marque’), I managed to have it with the code below but it appears below the price

    add_action( ‘woocommerce_after_shop_loop_item’, ‘acf_template_loop_product_meta’, 20 );
    function acf_template_loop_product_meta() {
    global $product;

    // Check that we got the instance of the WC_Product object, to be sure (can be removed)
    if( ! is_object( $product ) ) {
    $product = wc_get_product( get_the_id() );
    }

    echo ‘<h4>’ . $product->get_attribute(‘pa_marque’) .'</h4>’;
    }

    https://i.postimg.cc/PrJVchTm/Capture.jpg

    Many thanks for your help
    David

  • Hi there,

    Try replacing the woocommerce_after_shop_loop_item to woocommerce_shop_loop_item_title.

  • Hi Alvind,

    I’ve tried your solution and the attribute is now displayed below the title, and actually it works great 🙂
    Thanks!

  • Glad to hear that! 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.