Reputation: 71
I've been trying to edit a main theme file in order to show the product title on image hover. We have a similar function, but actually shows the categories of the product, not his title.
Here's the code I've been trying to edit in order to get the products title:
<div class="bg-overlay"></div>
<a href="<?php the_permalink(); ?>" class="link-overlay"></a>
<div class="text-on-hover-wrap">
<?php do_action( 'woocommerce_after_shop_loop_item_title' ); ?>
<?php
if ( $woocommerce && version_compare( $woocommerce->version, '3.0', '>=' ) ) {
echo '<div class="categories">' . wc_get_product_category_list( $product->get_id() ) . '</div>';
} else {
echo '<div class="categories">' . $product->get_categories() . '</div>';
}
?>
</div>
I just want to get the product title instead of the categories terms.
Print of the style: https://prnt.sc/WZIgbMQNAb_5
Any help would be grateful!
Upvotes: 1
Views: 621
Reputation: 1545
You need to replace this code section.
if ( $woocommerce && version_compare( $woocommerce->version, '3.0', '>=' ) ) {
echo '<div class="categories">' . wc_get_product_category_list( $product->get_id() ) . '</div>';
} else {
echo '<div class="categories">' . $product->get_categories() . '</div>';
}
to this.
echo '<div class="categories">' . $product->get_title() . '</div>';
Upvotes: 1