WordPress.org

Forums

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

  1. Will24_
    Member
    Posted 1 year 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 10 months ago #

    Thanks

  3. onl9m8
    Member
    Posted 5 months ago #

    any idea?

  4. arpenoo
    Member
    Posted 5 months ago #

    Me too !

  5. NiklasTeich
    Member
    Posted 5 months 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 5 months ago #

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

  7. Watch Teller
    Member
    Posted 5 months ago #

    +1

  8. afzalCoder
    Member
    Posted 4 months 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 4 months ago #

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

    tks

  10. afzalCoder
    Member
    Posted 4 months ago #

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

  11. RXC
    Member
    Posted 4 months 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 4 months 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 4 months 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 4 months ago #

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

  15. RXC
    Member
    Posted 4 months 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 4 months ago #

    It's ok, tks!

  17. PatrizioRD
    Member
    Posted 3 months ago #

    Thanks @afzalCoder, I put the whole snippets together and this worked like a charm for me.

    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 || strpos($output, '<span class="breadcrumb_last"') > 0 ){
    
                            $output = '<a property="v:title" rel="v:url" href="'. $crumb['url']. '" >';
                            $output.= $crumb['text'];
                            $output.= '</a>';
                        }
    
                return $output;
    }
  18. afzalCoder
    Member
    Posted 3 months ago #

    Glad, that it worked for you.
    Also, I have put up an article here

  19. NiklasTeich
    Member
    Posted 3 months ago #

    Awesome, that works for me - thanks for that!

  20. debabrat22
    Member
    Posted 3 months ago #

    But the 3rd breadcrumb url is neither showing in google structured data testing tool nor in google search result.

    in both cases the fist 2 urls are showing.
    Please look into this issue.

  21. Blair
    Member
    Posted 3 months ago #

    Thanks @afzalCoder
    http://www.wp-hacks.com/add-url-to-last-breadcrumb/
    solved my Breadcrumb 2 issue.

    Is anyone looking into a solution for Breadcrumb 3?

    Breadcrumb 3 is still putting out errors:
    Breadcrumb 3
    url: missing and required

  22. jbericat
    Member
    Posted 3 months ago #

    Hi,

    same problem as debabrat22 here. Any suggestion?

    Thanks!

  23. gfowke
    Member
    Posted 3 months ago #

    Hi,

    Same problem as debabrat22 and jbericat. Breadcrumb 3 not putting out a URL so showing as error on Google's Structured Data testing tool.

    Any ideas?

  24. caroline
    Member
    Posted 3 months ago #

    Thanks for this!

  25. debabrat22
    Member
    Posted 2 months ago #

    Please somebody tell me why my 3rd breadcrumb is not showing in google search results as well as google structured data.

    Lets us say my post is

    http://www.smartgsmdeals.com/iphone-6-review/

    But in google result iphone-6-review is missing rather it is showing as
    http://www.smartgsmdeals.com/blog

    as i have created a static landing page as well as blog page.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress SEO by Yoast
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic