Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. <?php
  2.  
  3. //Truncate Breadcrumb title
  4.  
  5. function truncate_breadcrumb_title() {
  6. // Get the title of the current post.
  7. if(WPSEO_Meta::get_value( 'bctitle', get_the_ID())){
  8. $title = WPSEO_Meta::get_value( 'bctitle', get_the_ID());
  9. }else{
  10. $title = get_the_title();
  11. }
  12.  
  13. // Determine the length of the title.
  14. $title_length = strlen( $title );
  15. // Set a limit for the breadcrumb title.
  16. $limit = 25;
  17. // Truncate the title.
  18. $truncated = substr( $title, 0, $limit );
  19. // Add an ellipsis if the title has been truncated.
  20. if ( $title_length > $limit ) {
  21. $truncated .= '...';
  22. }
  23. $link['text'] = $truncated;
  24. return $link['text'];
  25. }
  26. add_filter('wp_seo_get_bc_title', 'truncate_breadcrumb_title');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement