Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Truncate Breadcrumb title
- function truncate_breadcrumb_title() {
- // Get the title of the current post.
- if(WPSEO_Meta::get_value( 'bctitle', get_the_ID())){
- $title = WPSEO_Meta::get_value( 'bctitle', get_the_ID());
- }else{
- $title = get_the_title();
- }
- // Determine the length of the title.
- $title_length = strlen( $title );
- // Set a limit for the breadcrumb title.
- $limit = 25;
- // Truncate the title.
- $truncated = substr( $title, 0, $limit );
- // Add an ellipsis if the title has been truncated.
- if ( $title_length > $limit ) {
- $truncated .= '...';
- }
- $link['text'] = $truncated;
- return $link['text'];
- }
- add_filter('wp_seo_get_bc_title', 'truncate_breadcrumb_title');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement