So, I’d like to display custom attributes under the product title on the shop page (beside just the price and the title).
I’ve been recommended the following:
…from within the WooCommerce cart contents loop (the $_product variable is then available to you) you can use the ‘get_attributes( ‘attribute-slug’ )’ function to retrieve any product attribute, where ‘attribute-slug’ is any attribute slug, like so:
‘<?php echo $_product->get_attribute( ‘attribute-slug’ );?>’
Thanks for forgetfuljames. But it does not work for me , unfortunately. I put it right after the title, as in
‘ <h3><?php the_title(); ?></h3>
<?php echo $_product->get_attribute( ‘budget’ );?>’
but it only shows me Fatal error: Call to a member function get_attribute() on a non-object in
What worked is when I copied the whole product-attribute.php file content into the content-product.php (relevant place). But I’m sure it’s too basic to do it this way.
Is there any way to do the filter/hook thing there? Or do the previous way, but fix whatever is not working for me?
Thank you so much for the response!
- The topic ‘How to pull custom attributes for product on shop/category page’ is closed to new replies.