Product structured data tweak

This commit is contained in:
claudiulodro 2019-01-04 07:51:22 -08:00
parent cea9b59523
commit 5a005d9ee9
1 changed files with 6 additions and 0 deletions

View File

@ -329,6 +329,12 @@ class WC_Structured_Data {
$markup['itemListElement'] = array(); $markup['itemListElement'] = array();
foreach ( $crumbs as $key => $crumb ) { 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( $markup['itemListElement'][ $key ] = array(
'@type' => 'ListItem', '@type' => 'ListItem',
'position' => $key + 1, 'position' => $key + 1,