This topic has 4 replies, 3 voices, and was last updated 2 years, 9 months ago ago by Olga Barlow
Hi. I need to change the product title adding a custom (dynamically) other text.
there is a hook called woocommerce_before_shop_loop_item_title but doesnt work.
i read the forum and found this other 2 hooks
et_before_shop_loop_title and et_after_shop_loop_title
BUT
et_before_shop_loop_title = prints my custom text before the title – not a solution.
et_after_shop_loop_title = prints the product price and then adds my custom text.
how can i resolve this ? thanks
Hello,
Additional customization in files is outside the scope of our support, but we will check what can be done to help you. Please provide temporary wp-admin and FTP access. Then I will pass your question to one of our dev team.
Regards
I did it in this way.. please tell me if it is ok and nothing will be broken on future
remove_action('woocommerce_after_shop_loop_item_title','woocommerce_template_loop_price', 10 );
function customize_shop_page_product_title() {
$custom = 'hello!';
echo '<h4 class="product-title"><a href="'.get_the_permalink().'">'.$custom.'</a></h4>';
woocommerce_template_loop_price();
}
add_action('woocommerce_after_shop_loop_item_title','customize_shop_page_product_title', 10);
Hello,
You may add next custom code in your child-theme/functions.php
add_filter('the_title', function($title, $id) {
if ( in_array(get_post_type($id), array('product', 'product_variation') ) ) {
$title .= ' ' . __('Your custom text', 'xstore');
}
return $title;
}, 10, 2);
https://gyazo.com/45e8dadd9c96a6bc16f51ec50ce86181
Regards
You must be logged in to reply to this topic.Log in/Sign up