A
A
AltaiR2016-09-05 21:18:25
Web development
AltaiR, 2016-09-05 21:18:25

How to change product list markup in woocommerce?

Goodnight. In the catalog of goods I want to set a class for the names of goods. In the file content-product.php, this hook is responsible for displaying the name woocommerce_template_loop_product_title. And it is located along the path includes/wc-template-functions.php . Here is the piece of code itself:

/**
     * Show the product title in the product loop. By default this is an H3.
     */
    function woocommerce_template_loop_product_title() {
        echo '<h3>' . get_the_title() . '</h3>';
    }

Editing this code would solve my issue, but after updating the plugin, everything will fly off.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Kozlov, 2016-09-06
@AltaiR-05

Delete the woo hook. You add a new one with a link to your function. This can be placed in functions.php

remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
add_action( 'woocommerce_shop_loop_item_title', 'custom_woocommerce_template_loop_product_title', 10 );
function custom_woocommerce_template_loop_product_title() {
echo '<h3 class="myclass">' . get_the_title() . '</h3>';
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question