WooCommerce Product Widget, Limit Product Titles on Home Page
-
Hi There,
I’m using the widget “WooCommerce Products” on my home page and I need to shorten the titles.
I’ve been able to successfully shorten the titles on my shop page using this code;
add_filter( 'the_title', 'shorten_my_title', 10, 2 ); function shorten_my_title( $title, $id ) { if ( is_shop() && get_post_type( $id ) === 'product' ) { return substr( $title, 0, 50 ); // change 50 to the number of characters you want to show } else { return $title; } }
But since I’m working with products that are being listed due to a widget, the same function doesn’t work if I replace “shop” with “home.” Any suggestions?
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘WooCommerce Product Widget, Limit Product Titles on Home Page’ is closed to new replies.