WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Add URL to last breadcrumb (16 posts)

  1. Will24_
    Member
    Posted 10 months ago #

    Hi.

    Here's an example of a breadcrumb generated by the WordPress SEO by Yoast plugin:

    "My Website > Stuff > This Page"

    As you can see, "This Page" is not pointing to anywhere. So it appears in Google as this:

    My Website > Stuff

    I would like it to appear as this:

    My Website > Stuff > This Page

    How can I do that?

    https://wordpress.org/plugins/wordpress-seo/

  2. Will24_
    Member
    Posted 5 months ago #

    Thanks

  3. onl9m8
    Member
    Posted 1 month ago #

    any idea?

  4. arpenoo
    Member
    Posted 1 month ago #

    Me too !

  5. NiklasTeich
    Member
    Posted 1 month ago #

    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

  6. onl9m8
    Member
    Posted 1 month ago #

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

  7. Watch Teller
    Member
    Posted 3 weeks ago #

    +1

  8. afzalCoder
    Member
    Posted 1 week ago #

    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;
    }
  9. fabioamv
    Member
    Posted 5 days ago #

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

    tks

  10. afzalCoder
    Member
    Posted 5 days ago #

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

  11. RXC
    Member
    Posted 1 day ago #

    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;
    }
  12. afzalCoder
    Member
    Posted 1 day ago #

    @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 )
  13. fabioamv
    Member
    Posted 1 day ago #

    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);

  14. afzalCoder
    Member
    Posted 1 day ago #

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

  15. RXC
    Member
    Posted 1 day ago #

    @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.

  16. fabioamv
    Member
    Posted 1 day ago #

    It's ok, tks!

Reply

You must log in to post.

About this Plugin

About this Topic