Support » Plugin: Yoast SEO » [Plugin: WordPress SEO by Yoast] wp_seo_get_bc_ancestors filter unreliable

  • Resolved Alexander Gieg


    WordPress version: 3.3.2
    WordPress SEO version: 1.2.1

    I did this:

    Attempted to use the new wp_seo_get_bc_ancestors filter.

    I expected the plugin to do this:

    Well, after adding a function of mine to the filter, I expected to receive an array with all the ancestor for the pages. Given most of my pages have two ancestors (plus the home page), I expected the array to have at least two entries.

    Instead it did this:

    The function was never triggered. Looking at the original function in which the filter is called (function breadcrumb in frontend/class-breadcrumbs.php line 110), I noticed it’s called only once, and under a very limited set of conditions that don’t encompass the whole set of URLs the function finds.

    My suggestion would be to rework the function so that the URLand title finding happens first, filling the $ancestors, which then gets filtered, and only then this returned array gets processed and turned into the visible $output variable.

    Since I’m quite interested in having this working for my current project, and I see there are other more urgent issues with the new version given what people are talking about in the forum, I’d like to offer to do this myself then post Pastebin link to the reworked function here. What do you think?

    By the way: the new version is quite nice. Kudos!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Joost de Valk


    Patches welcome Alexander, I’m not planning on writing the code myself though 🙂

    Hehe, I can see why. 🙂 I’ll do this and link to the reworked version later today or by Monday.

    By the way: I plan to improve the returned array in a way that’ll most certainly break backwards compatibility with the current version, but as it’s probably being used by no one right now, I doubt it’ll cause problems.

    And on a side note: my pt_BR translation is almost complete. After this code I’ll also add a new set of i18n-related suggestions.

    Hi! Here’s my proposed new version for the breadcrumb function: WPSEO Breadcrumbs at Pastebin.

    With it, the wp_seo_get_bc_ancestors filter gets and returns an array of arrays similar to this one, in the same order displayed, which makes it quite easy to iterate through it and add, remove or change things as needed:

    $breadcrumb_array[n] = {
          'title' => (string),
          'url' => (string),
          'class' => (string),
          'type' => (string),
          'ID' => (int)

    I’ve tested it with the site I’m developing and it works very well, although more testing is certainly needed.

    PS.: I included the patches suggested by thomask at small error notice in breadcrumbs l. 226.

    +1 – please Yoast, use Alex’s function, works as a charm, i have tested it and it solve several problems with your breadcrumbs, i have reported in past weeks

    Fixed a bug pointed by thomask. The new version is in the original link.

    P.S.: Here’s a diff/patch version that makes it easier to see what’s changed between the current official function and my current customized version: WPSEO Breadcrumbs (Diff version).

    I’ve uploaded another update. This one adds support to Rich Snippets as suggested by Rajesh Namase. I’ve taken care to not include the rich snippet tags for the current page (it seems to be ignored anyway) or for the home page if present (IMHO it makes the snippet breadcrumb path excessively long, but if someone thinks it’d be better to include it just tell me and I’ll change the proposed code).

    I hope this helps!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: WordPress SEO by Yoast] wp_seo_get_bc_ancestors filter unreliable’ is closed to new replies.