Add Product Attributes to Archive Pages in WooCommerce

If you’re using WooCommerce to power your online store, then you’ll want to take advantage of its powerful archive pages. These pages can be used to show off your products in a variety of ways, and with a little bit of customization, you can add product attributes to them. This can help customers find the products they’re looking for quickly and easily. In this article, we’ll show you how to add product attributes to archive pages in WooCommerce.

woocommerce_after_shop_loop_item action adds data to the bottom of each product.

add_action('woocommerce_after_shop_loop_item', 'my_theme_display_product_category', 10);
function my_theme_display_product_category(){
    global $product;
    if ( $product->has_attributes() ) {
        $colors = $product->get_attribute('pa_color');            
        echo $colors;
    }    
}

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close