AI Verified

Name

Limit WooCommerce product title to a specific length

About

Limit WooCommerce product title in the first line

Language

PHP

Rating

Voted: 0 by 0 user(s)

How to Setup Snippet

Just copy and paste the code to codesnippets plugin

Codevault

devtanvir

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.1

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

Website/ Profile URL:

https://devtanvir.me/

History

Last modified:

22/11/2022

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Found 0 vulnerabilities

Limit WooCommerce product title to a specific length

 
                    
1add_filter( 'the_title', 'shorten_woo_product_title', 10, 2 );
2function shorten_woo_product_title( $title, $id ) {
3 if ( ! is_singular( array( 'product' ) ) && get_post_type( $id ) === 'product' && strlen( $title ) > 30 ) {
4 return substr( $title, 0, 30) . '…'; // change last number to the number of characters you want
5 } else {
6 return $title;
7 }
8}

0

Related Snippets

Please see some snippets below related to this snippet..

WooCommerce

AI Verified

0

Change number of related products on product page

Added: 1 year ago

Last Updated: 1 year ago

The so called "Related Products" are a great thing, however you might want to influence the output of these similar items a bit. This code takes care of that.

WooCommerce

AI Verified

1

WooCommerce Change “Choose Some Product Options” Text

Added: 1 year ago

Last Updated: 2 weeks ago

A lot of the time, users will miss the attribute drop down on a variable product page and immediately go for the add to cart button. If this happens, and the user has not yet selected an option from t...

WooCommerce

AI Verified

1

Change 'add to cart' text

Added: 1 year ago

Last Updated: 3 months ago

https://www.codegearthemes.com/blogs/woocommerce/woocommerce-how-to-change-add-to-cart-button-text

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

WooCommerce

AI Verified

1

Hide Other Shipping Methods When Free Shipping Available

Added: 1 year ago

Last Updated: 1 year ago

Hide Other Shipping Methods When Free Shipping Available

WooCommerce

AI Verified

0

Limit WooCommerce product title to a specific length

Added: 1 year ago

Last Updated: 1 year ago

Limit WooCommerce product title in the first line

WordPress Admin

AI Verified

0

Disable Gutenberg Editor and back to Classic Widgets

Added: 1 year ago

Last Updated: 1 year ago

Disable Gutenberg Editor and back to Classic Widgets