Breadcrumbs doesn’t include the blog top (root) page

#157680
  • Resolved 中村 真由美
    Rank Math free

    Hi, thanks you for offering the great plugin & support as always.
    Looking at the sample page, this page’s breadcrumbs has the following structure
    Home > Category > Post Title

    However, ideally I want this to be like
    Home > Blog Top(/blog) > Category > Post Title

    Would it be possible?

    Regards,
    Mayumi

Viewing 3 replies - 1 through 3 (of 3 total)
  • Prabhat
    Rank Math agency

    Hello,

    Thanks for contacting us!

    Rank Math doesn’t provide that feature by default but you can achieve it using custom code and filters. Please check and modify the below code then add it in the end of your themes function.php file to add the Blog page in your breadcrumbs:

    
    /**
     * Allow changing or removing the Breadcrumb items
     *
     * @param array       $crumbs The crumbs array.
     * @param Breadcrumbs $this   Current breadcrumb object.
     */
    
    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	if(is_singular('post')||is_category()){
    		array_splice( $crumbs, 1, 0, array(array(
    			"Blog",
    			"https://yourwebsite.com/blog/",
    			"hide_in_schema" => false
    		)) );
            }
    	return $crumbs;
    }, 10, 2);
    

    Please let us know how that goes.

    Thanks!

    Hi Prabhat,

    The code perfectly worked. Hope we have this as a default function in the future update.
    Thanks!

    Mayumi

    Prabhat
    Rank Math agency

    Hello,

    We are glad that we could address your issue.

    We will be including many amazing features to Breadcrumbs in the coming updates. For more details, you can keep an eye on our changelog: https://rankmath.com/changelog/

    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 3 replies - 1 through 3 (of 3 total)

The ticket ‘Breadcrumbs doesn’t include the blog top (root) page’ is closed to new replies.