Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. // filter the product title
  2. add_filter( 'the_title', 'wtl_shorten_my_product_title', 10, 2 );
  3.  
  4. // limit product title on shop and category page
  5. function wtl_shorten_my_product_title( $title, $id ) {
  6.     $option = get_option('wtl_opt');
  7.     if(is_plugin_active('woocommerce/woocommerce.php')){
  8.         if ( is_product_category() || is_shop() && get_post_type( $id ) === 'product' ) {
  9.             return substr( $title, 0, $option['wtl_count'] );
  10.         } else {
  11.             return $title;
  12.         }
  13.     }else {
  14.         return $title;
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement