Show Name/Slug of Category on Permalink using Breadcrumb

If you have already added dynamic breadcrumb schema on WordPress website, and you want to showing category’s name on search result’s url. So change or add something in breadcrumb schema code.

How to Do

There are two different codes, you can use them as per your requirement on your website. So i share code with examples

1 – When showing category’s name

https://www.domain.com/How To
{Showing on search engine’s result}

<?php
$cat = get_the_category();
echo $cat[0]->cat_name;}
?>

2 – When showing category’s slug

https://www.domain.com/how-to
{Showing on search engine’s result}

<?php
$cat = get_the_category();
echo $cat[0]->cat_slug;}
?>

Simply change cat_name to cat_slug. If this code not worked on your website, So contact us. Thanks for visiting