Merge pull request #22344 from woocommerce/fix/breadcrumbdata

Product structured data tweak to show both BreadcrumbList and Product structured data.
This commit is contained in:
Mike Jolley 2019-01-07 13:49:54 +00:00 committed by GitHub
commit 9ce3f408a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -329,6 +329,12 @@ class WC_Structured_Data {
$markup['itemListElement'] = array();
foreach ( $crumbs as $key => $crumb ) {
// Don't add the current page to the breadcrumb list on product pages,
// otherwise Google will not recognize both the BreadcrumbList and Product structured data.
if ( is_product() && count( $crumbs ) - 1 === $key ) {
continue;
}
$markup['itemListElement'][ $key ] = array(
'@type' => 'ListItem',
'position' => $key + 1,