Remove breadcrumb items and separator

#444778
  • Resolved David Macfarlane
    Rank Math free

    Hi

    My breadcrumbs look this this

    Home > One > Two > Three > Four

    I would like to remove One and Two, which I have done as follows:

    add_filter( ‘rank_math/frontend/breadcrumb/items’, function( $crumbs, $class ) {
    $crumbs[1] = null;
    return $crumbs;
    }, 10, 2);

    add_filter( ‘rank_math/frontend/breadcrumb/items’, function( $crumbs, $class ) {
    $crumbs[2] = null;
    return $crumbs;
    }, 10, 2);

    However, this leaves the breadcrumbs looking like this:

    Home > > > Three > Four

    Is there a filter I can use to remove the redundant separators?

    Thank you

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    In this case, you may need to use unset for the breadcrumbs instead. Assigning null will return an empty value, leaving the separator.

    Using unset will remove the specific breadcrumb totally with the separator.

    Could you please try using this filter instead?

    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
           unset($crumbs[1]);
           unset($crumbs[2]);
           return $crumbs;
    }, 10, 2);

    Let us know how this goes.

    Thank you.

    Hi

    That kind of worked, but left me with this:

    Home » Three » Four »

    Four is hyperlinked, and it has a trailing >>

    https://staging-hoaorguk.kinsta.cloud/advice/guides-for-homeowners/i-am-buying/gifted-deposits/

    Hello,

    We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress login in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    ..

    Nigel
    Rank Math business

    Hello,

    Thank you for your patience as we look into how to adjust your breadcrumbs.

    I have modified the code snippet to the one below:

    
    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
      if (count($crumbs)== 5){
        $crumbs[1]=$crumbs[3];
        $crumbs[2]=$crumbs[4];
        unset($crumbs[3]);
        unset($crumbs[4]);
    }
    
    return $crumbs;
    }, 10, 2);
    

    Hope that helps. Please let us know if you have questions.

    Thank you!

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)

You must be logged in to reply to this ticket.