Duplicate FAQPage Schema on Archive pages

I am using FAQ Accordion component with FAQ Schema on several pages and posts.

I am receiving a "Duplicate field “FAQPage” error in Google Search Console for the blog and archive pages.

For example, FAQPage is injected for each post that has a FAQ Schema on the blog page: https://www.bellafsm.com/blog/

How do I disable FAQ Schema for blog and archive pages?

Hello @jnlinn,

Thank you for the info.

We didn’t see any errors when we ran the test on Schema Validator and Google Rich Results Test.

We also noticed that you added the following script:

<script>
  document.addEventListener('DOMContentLoaded', function() {
    if (document.body.classList.contains('blog') || document.body.classList.contains('archive')) {
      document.querySelectorAll('script[type="application/ld+json"]').forEach(function(script) {
        try {
          var data = JSON.parse(script.textContent);
          if (data['@type'] === 'FAQPage') {
            script.remove();
          }
        } catch (e) {}
      });
    }
  });
</script>

Did this fix the issue?

Best regards,

I have been trying different scripts to remove the FAQPage Schema from the blog and archive pages but none are working. I just removed the script you saw.

Schema.org shows two FAQPage’s but does not consider it an issue.

However, Google’s Rich Results and Search Console consider it an error. Here is the Rich Results:

Are you able to provide me the script to add to my functions.php to disable FAQPage Schema on the blog and archive pages?

Hi @jnlinn,

While retesting the URL in the Google Rich Results Test, I found the issue you described here. I would suggest removing the code mentioned by my colleague in his reply and retesting to check if that resolves your problem. If not, please provide login credentials for your site in a secure note to examine it further, including:

– WordPress Site URL & Login URL
– WordPress Admin username/password

To create a secure note, click the key icon underneath any of your posts.

NOTE: Please remember that we don’t offer any support for the custom code or related issues.

Thanks

As I mentioned, I already removed the code. That code did not create the issue, I was testing different scripts to fix the issue.

I do not think it is necessary to log into my account. It’s obvious the blog and archive pages are injecting the FAQ Schema for each post on the blog and archive pages. Look at https://www.bellafsm.com/blog/ page source code and you will see two FAQPage scripts at the bottom. Two of the posts on the blog page have FAQ Schema.

Are you able to provide the script to add to functions.php to disable FAQPage Schema on the blog and archive pages?

Thank you for the update. We’ll forward the issue to our channel. In the meantime, try editing the cornerstone/includes/elements/definitions/accordion.php file and modify the code around line 192:

$faq_schema['@context'] = 'https://schema.org';
  $faq_schema['@type'] = 'FAQPage';
  $faq_schema['mainEntity'] = [];

Replace it with:

$faq_schema['@context'] = 'https://schema.org';
  $faq_schema['@type'] = 'FAQPage';
  $faq_schema['@id'] = '/faq';
  $faq_schema['mainEntity'] = [];

Let us know if the issue persists.

That worked! It combined the multiple FAQPage’s into one. Thank you.

You are most welcome, @jnlinn.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.