Hide Breadcrumb if only one item is available

#325817
  • Resolved jdoe12
    Rank Math free

    Hello there,
    I would like to hide the Breadcrumb bar on pages/posts where only one item would be shown.

    I tried by my own with the filter below, but the Breadcrumb bar is still displayed when I check the HTML source code – even if the array is empty.

    add_filter(‘rank_math/frontend/breadcrumb/items’, function ($crumbs, $class) {

    if (!empty($crumbs) && is_array($crumbs)):
    if (count($crumbs) > 1):
    return $crumbs;
    endif;
    endif;

    unset($crumbs[0]);

    //print_r($crumbs);
    return array_values($crumbs);
    }, 10, 2);

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

    Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.

    Could you please test the following modified filter to achieve the desired result on your website?

    
    add_filter( 'rank_math/frontend/breadcrumb/html', function( $html, $crumbs, $class ) {
        if (!empty($crumbs) && is_array($crumbs)):
            if (count($crumbs) > 1):
                return $html;
            endif;
        endif;
    
        $html = '';
    
        return $html;
    }, 10, 3);
    

    ​​​​​​​Let us know if this helps fix the issue.

    Looking forward to hearing back from you.

    Hi Miguel,

    That works. Thank you very much.

    Hello,

    You’re welcome.

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

    If you don’t mind us 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 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 3 replies - 1 through 3 (of 3 total)

The ticket ‘Hide Breadcrumb if only one item is available’ is closed to new replies.