Advertisement
wclovers

Untitled

Aug 30th, 2023
777
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.35 KB | None | 0 0
  1. add_filter('the_title', function ($post_title, $post_id) {
  2.     $post = get_post($post_id);
  3.  
  4.     if ('product' == $post->post_type && !is_single($post_id) && !is_admin()) {
  5.         $length = 22;
  6.         $post_title = (mb_strlen($post_title) > $length) ? (mb_substr($post_title, 0, $length) . "...") : $post_title;
  7.     }
  8.  
  9.     return $post_title;
  10. }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement