I lately put in a plugin for wordpress/woocommerce that permits you to select a major class for a product when it is in a number of classes. It really works effectively to vary the breadcrumbs, however my theme (peakshops) additionally shows the first class underneath the corresponding thumbnails on the the store web page.
That is the core operate that’s constructed into the theme to show the class (and hyperlink to the class) underneath the thumbnail:
// Add Title with Hyperlink.
operate thb_template_loop_product_title() {
international $product;
$product_url = apply_filters( 'woocommerce_loop_product_link', get_the_permalink(), $product );
?>
<?php
if ( 'on' === ot_get_option( 'shop_product_listing_category', 'on' ) ) {
$shop_product_listing_category_single = ot_get_option( 'shop_product_listing_category_single', 'on' );
?>
<div class="product-category">
<?php
if ( 'on' === $shop_product_listing_category_single ) {
$product_cats = wc_get_product_category_list( get_the_ID(), 'n', '', '' );
if ( $product_cats ) {
record( $first_part ) = explode( 'n', $product_cats );
echo wp_kses(
$first_part,
array(
'a' => array(
'href' => array(),
'rel' => array(),
),
)
);
}
} else {
echo wc_get_product_category_list( $product->get_id(), ', ' );
}
?>
</div>
<?php } ?>
<h2 class="<?php echo esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ); ?>"><a href="<?php echo esc_url( $product_url ); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php
}
add_action( 'woocommerce_shop_loop_item_title', 'thb_template_loop_product_title', 10 );
This core operate appears to seize the primary class relatively than the first class assigned by the plugin. Is there a solution to change this motion (or take away it and create a brand new one) in order that it references the first class assigned. For reference, the first class plugin shops the worth as a submit meta area like this: