From 5a005d9ee9db6679af06f93e229ff7c96af43515 Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Fri, 4 Jan 2019 07:51:22 -0800 Subject: [PATCH] Product structured data tweak --- includes/class-wc-structured-data.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/class-wc-structured-data.php b/includes/class-wc-structured-data.php index a0bc94360eb..4d3911c963a 100644 --- a/includes/class-wc-structured-data.php +++ b/includes/class-wc-structured-data.php @@ -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,