Breadcrumbs

#715181
  • Resolved Tatiana
    Rank Math free

    breadcrumbs the single page not show breadcrumbs Categories. how to show single post breadcrumbs Categories

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello, we apologize for the inconvenience you’re facing with the breadcrumbs on your single page. To show the categories in the breadcrumbs of your single posts, you can use the following filter:

    /** 
    * Filter to display categories in Rank Math Breadcrumbs. 
    */ 
    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) { 
            // check if we are viewing single posts
    
            if(is_singular('post')){ //Unset elements with key 1        
              unset($crumbs[1]); 
              $crumbs = array_values($crumbs);      
              return $crumbs;   
            }   
            return $crumbs; 
    }, 10, 2);

    You can add this filter to your site and it will display the categories in the breadcrumbs of your single posts. If you have any further questions or need assistance, feel free to reach out to our dedicated support team here. We’re available 24/7, 365 days a year.

    Sources:
    How to Customize Breadcrumbs in Rank Math » Rank Math
    How to Enable Breadcrumbs on Your Website With Rank Math SEO » Rank Math

    I’m using generatepress theme. where i add this code:

    /**
    * Filter to display categories in Rank Math Breadcrumbs.
    */
    add_filter( ‘rank_math/frontend/breadcrumb/items’, function( $crumbs, $class ) {
    // check if we are viewing single posts

    if(is_singular(‘post’)){ //Unset elements with key 1
    unset($crumbs[1]);
    $crumbs = array_values($crumbs);
    return $crumbs;
    }
    return $crumbs;
    }, 10, 2);

    Hello,

    Apologies for the confusion, but the code above is not correct to show the breadcrumbs.

    Usually, themes include header.php and single.php files which is the best place to insert breadcrumbs:
    https://rankmath.com/kb/breadcrumbs/#theme-template-files

    If the breadcrumbs are still not showing upon inserting it into those files, then we suggest checking with Generatepress to help you add the breadcrumbs code to your theme as they know best their theme structure and where to insert the code to get the desired result.

    Hope that helps.

    Thank you. it’s solved.

    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.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘Breadcrumbs’ is closed to new replies.