From d029369839313b403968e4f9517353578d012bfe Mon Sep 17 00:00:00 2001 From: Joaquim d'Souza Date: Tue, 14 Nov 2023 16:18:14 +0100 Subject: [PATCH] fix: broken yoast breadcrumbs in webpage schema --- web/app/themes/awasqa/functions.php | 9 ++++++++- web/app/themes/awasqa/src/wpml.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/web/app/themes/awasqa/functions.php b/web/app/themes/awasqa/functions.php index 6450429..41452a3 100644 --- a/web/app/themes/awasqa/functions.php +++ b/web/app/themes/awasqa/functions.php @@ -157,4 +157,11 @@ return null; } return $value; -}, 10, 3); \ No newline at end of file +}, 10, 3); + +// Remove breadcrumbs from yoast site schema as Google thinks they are invalid +add_filter('wpseo_schema_graph_pieces', function ($pieces, $context) { + return \array_filter($pieces, function ($piece) { + return ! $piece instanceof \Yoast\WP\SEO\Generators\Schema\Breadcrumb; + }); +}, 11, 2); diff --git a/web/app/themes/awasqa/src/wpml.php b/web/app/themes/awasqa/src/wpml.php index 27dd7bd..1c26048 100644 --- a/web/app/themes/awasqa/src/wpml.php +++ b/web/app/themes/awasqa/src/wpml.php @@ -257,7 +257,7 @@ function connect_translations_page() add_filter('get_block_templates', function ($query_result, $query, $template_type) { if ($template_type !== "wp_template") { - return; + return $query_result; } $not_found_text = __('Not found: %1$s (%2$s)'); $not_found_part = explode(":", $not_found_text)[0] . ": ";