Viewing 15 replies - 1 through 15 (of 24 total)
  • Thread Starter Will24_

    (@will24_)

    Thanks

    any idea?

    Me too !

    Correct, because the Google Structered Data Test Tool https://developers.google.com/webmasters/structured-data/testing-tool/ lists the last and missing breadcrumb URL as an error!

    An option to add the URL in the last breadcrumb would be awesome!

    Greetings,
    Niklas

    Y.Breadcrumbs vs. Google NEW Structured #1926
    https://github.com/Yoast/wordpress-seo/issues/1926

    +1

    I added the link to last breadcrumb using filter ‘wpseo_breadcrumb_single_link’

    add_filter( 'wpseo_breadcrumb_single_link', 'link_to_last_crumb' , 10, 2); 
    
      function link_to_last_crumb( $output, $crumb){          
    
                        if( /*last crumb*/ ){
    
                            $output = '<a property="v:title" rel="v:url" href="'. $crumb['url']. '" >';
                            $output.= $crumb['text'];
                            $output.= '</a>';
                        }
    
                return $output;
    }
    fabioamv

    (@fabioamv)

    Hi afzalCoder,
    where did you put this code? Did you change class-breadcrumbs.php?

    tks

    afzalCoder

    (@afzalcoder)

    @fabioamv Paste the code in theme’s function.php file

    RXC

    (@rxc)

    Hi afzalCoder, your code lacks of condition in if statement, hence not working.

    This is the WORKING version that needs to be pasted into functions.php:

    add_filter( 'wpseo_breadcrumb_single_link', 'link_to_last_crumb' , 10, 2); 
    
      function link_to_last_crumb( $output, $crumb){          
    
                        if( strpos($output, '<strong class="breadcrumb_last"') > 0 ){
    
                            $output = '<a property="v:title" rel="v:url" href="'. $crumb['url']. '" >';
                            $output.= $crumb['text'];
                            $output.= '</a>';
                        }
    
                return $output;
    }
    afzalCoder

    (@afzalcoder)

    @rxc
    Hi RXC, I purposefully left the condition in if statement.
    If the bold last page is not selected in back-end settings of WordPress SEO plugin, I think your condition will not work.

    So, the condition to work should be :

    if( strpos($output, '<strong class="breadcrumb_last"') > 0 || strpos($output, '<span class="breadcrumb_last"') > 0 )

    fabioamv

    (@fabioamv)

    tks, but I get this error:

    Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /var/www/fabioaugustovieira.com.br/public_html/wp-content/themes/blogmagic/functions/functions.php on line 1229

    The line error: add_filter( 'wpseo_breadcrumb_single_link', 'link_to_last_crumb' , 10, 2);

    afzalCoder

    (@afzalcoder)

    @fabioamv
    It seems error is related to missing ‘;’ or not closing parenthesis properly.
    Please double check it

    RXC

    (@rxc)

    @afzalcoder
    So true, I had taken for sure that the strong for the last breadcrumb is always shown, not an option. Now the code is fully functional. Thanks.

    fabioamv

    (@fabioamv)

    It’s ok, tks!

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘Add URL to last breadcrumb’ is closed to new replies.