'Using is_page() results in duplicate schema
I have different FAQ schema for different pages. When I test each page, the rich result test returns warning with duplicate FAQ schema. The FAQ schema is duplicated because the rich result detects the schema for other pages together with the tested page. How can I remove the duplicated schema?
My pages structure are as follow:
example.com/FAQ/page_name
example.com/FAQ/page_name02
example.com/FAQ/page_name03
My snippet:
add_action( 'wp_footer', function () { ?>
if ( is_page('page_name' ) ) {
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "",
"acceptedAnswer": {
"@type": "Answer",
"text": ""
}
}
]
}
</script>
endif;
}
<?php } );
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
