Hi @amboutwe
It is a standard blog post, we do have case studies, but they are working fine pulling in the correct information when looking at the Breadcrumb List’s.
We currently only use Yoast SEO code to create the breadcrumbs on our websites:
if ( function_exists('yoast_breadcrumb') )
{
yoast_breadcrumb('<div class="breadcrumb container">','</div>');
}
I think it’s due to our theme the reason we have 3 items showing this is on all our sites, only two of our sites so far have the issue with a missing name. Also, I couldn’t pinpoint what’s populating the missing name, I did use the health check plugin to check but as soon as I switched the theme over, it errored and took down the site… So, won’t be trying that option.
I then had a look at the Yoast SEO plugin code and noticed that there is a line of code within “wordpress-seo –> frontend –> schema –> class-schema-breadcrumb.php” That contains code stating if name is empty then change URL to title.
if ( empty( $breadcrumb['text'] ) ) {
$breadcrumb['url'] = $this->context->title;
}
This seemed slightly odd changing the $breadcrumb[‘url’] = title, when you’re looking to see if name is empty, don’t know if this is a bug/ typo within the plugin code?
To me, to stop the error this should have been $breadcrumb[‘text’] = “Some Default Value”; This also would have stopped the errors if the name was empty and the codes there, it’s just odd it wasn’t used?
e.g. example code plugin fix:
if ( empty( $breadcrumb['text'] ) ) {
$breadcrumb['url'] = $this->context->title;
$breadcrumb['text'] = "Some Default Value";
}
Anyway seeing that most of the code is there, I have added my own code to the plugin to fix the issue, I know this isn’t ideal as every time we update the plugin, we will need to add in the custom hard codded code to the plugin but at least this fixes the issue.
Hard codded code added to class-schema-breadcrumb.php:
if ( empty( $breadcrumb['text'] ) ) {
$breadcrumb['url'] = $this->context->title;
if (get_post_type() === 'post') {
$breadcrumb['url'] = "https://www.hiltonbairdaudit.co.uk/blog/";
$breadcrumb['text'] = "Blog";
}
}
Fixed output:
{
"@type":"BreadcrumbList",
"@id":"https://www.hiltonbairdaudit.co.uk/alan-baird-named-lecturer-of-the-year-again/#breadcrumb",
"itemListElement":[ {
"@type":"ListItem",
"position":1,
"item": {
"@type": "WebPage", "@id": "https://www.hiltonbairdaudit.co.uk/", "url": "https://www.hiltonbairdaudit.co.uk/", "name": "Home"
}
}
,
{
"@type":"ListItem",
"position":2,
"item": {
"@type": "WebPage", "@id": "https://www.hiltonbairdaudit.co.uk/blog/", "url": "https://www.hiltonbairdaudit.co.uk/blog/", "name": "Blog"
}
}
,
{
"@type":"ListItem",
"position":3,
"item": {
"@type": "WebPage", "@id": "https://www.hiltonbairdaudit.co.uk/alan-baird-named-lecturer-of-the-year-again/", "url": "https://www.hiltonbairdaudit.co.uk/alan-baird-named-lecturer-of-the-year-again/", "name": "Alan Baird named Lecturer of the Year again"
}
}
]
}
-
This reply was modified 5 years, 2 months ago by Matthew Utin.
-
This reply was modified 5 years, 2 months ago by Matthew Utin.
-
This reply was modified 5 years, 2 months ago by Matthew Utin.
-
This reply was modified 5 years, 2 months ago by Matthew Utin.
-
This reply was modified 5 years, 2 months ago by Matthew Utin.