Advertisement
jaideep06

Breadcrumbs Truncation

Dec 18th, 2022
972
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.43 KB | None | 0 0
  1. add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
  2.     $title = get_the_title();
  3.     $max_char_limit = 19; //Set the limit for breadcrumb title
  4.    
  5.     if(strlen($title) > $max_char_limit){
  6.         $RM_truncate_breadcrumb_title = substr($title, 0, $max_char_limit).'...';  
  7.         $crumbs[count($crumbs) - 1][0] = $RM_truncate_breadcrumb_title;
  8.         return $crumbs;
  9.     }  
  10.     return $crumbs;
  11. }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement