• Hi,

    Just a note for anyone looking to remove the parent category from the breadcrumbs (Internal Links) function of the WordPress SEO plugin by Yoast. If you’re not comfortable commenting out code, I wouldn’t suggest doing this.

    The context:
    I removed them for my blog because my blog title and the parent category name are the same, so I wanted it to go from this:
    Home > From The Ground Up (blog landing page link/name) > From The Ground Up (blog parent category link/name) > Child Category > Article Name
    to this:
    Home > From The Ground Up (blog landing page link/name) > Child Category > Article Name

    The code to edit:
    First, I enabled breadcrumbs.
    Then I commented out 2 areas in the plugins/wordpress-seo/frontend/class-breadcrumbs.php file in version 1.5.3.3 of the plugin:
    Line 483: I commented out the if statement that begins if ( is_taxonomy_hierarchical( $main_tax ) &&
    Line 516: commented out $this->maybe_add_preferred_term_parent_crumb( $term );
    Line 518 : commented out $this->maybe_add_term_parent_crumbs( $term );

    FYI:
    To be able to view your blog home page link in the breadcrumbs when on a tag page, I did not check the checkbox that says “Remove blog page from breadcrumbs” in the Breadcrumbs Settings. Checking this will make it so only the home page (site home page if different from blog home page) and tag to show as
    Home > tag name
    versus
    Home > From the Ground Up (blog title link/name) > tag name

    Hope this proves useful to others.
    https://www.ads-software.com/plugins/wordpress-seo/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi kemio

    I’m using Woocommerce and my breadcrumbs on my product page looks like this:
    Home / Products / Product Category / Product

    I want to remove the “Products /” part from the breadcrumbs so that it displays like this:
    Home / Product Category / Product

    Or at least like this:
    Home / Shop / Product Category / Product

    Currently the “Products” links redirects to mysite.com/shop therefore I would like it removed or the link renamed to “Shop”

    Do you know how to do it?

    Thread Starter kemio

    (@kemio)

    cgaybba: and you’re using the WordPress SEO plugin as well, right?

    Thread Starter kemio

    (@kemio)

    For your first option: There is a “Remove Blog page from Breadcrumbs” checkbox you can check which should remove your “Products” page from breadcrumbs assume that your your wp-admin > settings > reading is set up so your “Products” section is your “Posts page” in the “Front page displays” section.

    Otherwise, you can just rename your “Products” page “Shop”, for your second option.

    kemio, while your advice is no doubt well intended, it is in actual fact really bad practice as you are breaking the upgrade path for the plugin.

    The better (and easier) way to get the same result is to use the filters which are available in WPSEO.
    I think the wpseo_breadcrumb_links will be best suited for your purposes. It will provide you with an array of the basic crumbs. You can then (conditionally) remove the crumb you don’t want and return the resulting array and WPSEO will handle the rest.

    Thread Starter kemio

    (@kemio)

    @jfr Didn’t see that function. My way works for me. Good suggestion.

    When you need only first parent category – you may change:
    $parents[] = $term; (about line 189 in class-breadcrumbs.php)
    to:
    $parents[0] = $term;

    Then first of parents (0 = first element of array) will show in the breadcrumbs.

    It works for me:
    Before: home > cat-parent1 > cat-parent2 > cat-child > post
    After: home > cat-parent1 > cat-child > post

    I think $parents[1] = $term; could also work for the second of parents…

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Removing Parent Category from breadcrumbs WordPress SEO by Yoast’ is closed to new replies.