• Resolved Gabor Torda

    (@gabortorda)


    Hi,

    Is it possible to edit each individual link in the breadcrumb menu?

    Let’s say I have my WordPress set up with no slash at the end of URLs, also no redirects, so domain.com/products/ and domain.com/products both 200 OK.

    On the following page: domain.com/products/brush
    the breadcrumb looks like this: Home / Products / Brush
    URLs:
    Home: domain.com
    Products: domain.com/products
    Brush: not linked

    The question is, how can I make the Products URL with slash at the end: domain.com/products/
    ?

    Deeper links would not have the slash at the end, only the products slug.

    Thank you!

    • This topic was modified 4 years, 6 months ago by Gabor Torda.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Gabor Torda

    (@gabortorda)

    Just for the record, I could solve it:

    add_filter( ‘rank_math/frontend/breadcrumb/items’, function( $crumbs, $class ) {
    // if ( is_page(11)) {
    $breadcrumb[] = array(
    0 => ‘Products’,
    1 => ‘/products/’,
    );
    array_splice( $crumbs, 1, 1, $breadcrumb );
    // }
    return $crumbs;
    }, 10, 2);

    You have to specify 4 things:
    0 – name of the breadcrumb item, for instance Products
    1 – new url of the bredcrumb link
    $crumbs, 1, 1, (here you have to specify the breadcrumb number, it can be anything, for me it worked with 1, 1,)

    This code goes into the child theme’s function.php

    Plugin Author Rank Math

    (@rankmath)

    Hello @gabortorda

    Thank you for contacting the support.

    Glad you found the filter and are using it correctly.

    For anyone else, they can find all the filters here:
    https://rankmath.com/kb/filters-hooks-api-developer/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Modify Breadcrumbs URLs’ is closed to new replies.