How to Remove or Modify Schema Markup in All in One SEO
Content
Many WordPress users rely on All in One SEO (AIOSEO) to manage their website's structured data. However, there are common scenarios where you might need to disable or customize this automatically generated schema to prevent conflicts, meet specific search engine requirements, or integrate with other plugins.
Why You Might Need to Modify Schema
Based on community discussions, users typically need to alter their schema markup for a few key reasons:
- Preventing Duplicate Schema: When using another dedicated schema plugin, like Schema Pro, having two plugins outputting schema can create errors.
- Removing Specific Schema Types: Users often need to remove certain schema graphs, such as 'Person' for WooCommerce products or 'LocalBusiness' site-wide.
- Fixing Validation Errors: Search engines like Yandex or Google may report errors that require removing or modifying specific schema properties.
- Customizing for Specific Pages: There is often a need to disable schema on a single page, like a homepage, without affecting the entire site.
Common Solutions: Using Code Snippets
The primary method for modifying AIOSEO's schema output is by using WordPress filters, specifically the aioseo_schema_disable and aioseo_schema_output hooks. These code snippets are typically added to your child theme's functions.php file or via a code snippets plugin.
1. Disabling Schema Site-Wide
To completely turn off all schema markup generated by AIOSEO, use the following code:
add_filter( 'aioseo_schema_disable', 'aioseo_disable_schema' );
function aioseo_disable_schema( $disabled ) {
return true;
}
2. Disabling Schema on Specific Pages
To target schema removal more precisely, you can use conditional tags. For example, to remove schema only from the homepage:
add_filter( 'aioseo_schema_disable', 'aioseo_disable_schema' );
function aioseo_disable_schema( $disabled ) {
if ( is_front_page() ) {
return true;
}
return $disabled;
}
To remove a specific schema type, like Product schema on WooCommerce product pages:
add_filter( 'aioseo_schema_disable', 'aioseo_disable_schema_products' );
function aioseo_disable_schema_products( $disabled ) {
if ( is_singular( 'product' ) ) {
return true;
}
return $disabled;
}
3. Modifying Existing Schema Output
If you need to remove specific properties from within a schema graph, like datePublished or dateModified, you can use the aioseo_schema_output filter to manipulate the structured data array before it is output. Documentation for this advanced method can be found on the AIOSEO website.
Important Considerations
- Backup Your Site: Always back up your website before adding custom code.
- Use a Child Theme: Adding code to your
functions.phpfile is best done within a child theme to prevent your changes from being overwritten during theme updates. - Test Changes: After implementing any code, use a schema validator tool to check that the changes have taken effect and that your markup is error-free.
- Plugin Version: Be aware that some advanced schema customization features may be part of the Pro version of the plugin, and support for those features is handled directly by the All in One SEO team.
By understanding these common hooks and code snippets, you can gain greater control over your website's structured data and ensure it works seamlessly with your SEO strategy.
Related Support Threads Support
-
Main Entity Missing on Profile Page Schemahttps://wordpress.org/support/topic/main-entity-missing-on-profile-page-schema/
-
How can I add LiveBlogPosting schemahttps://wordpress.org/support/topic/how-can-i-add-liveblogposting-schema/
-
Hook for filter the url in the Schema ORG JS sectionhttps://wordpress.org/support/topic/hook-for-filter-the-url-in-the-schema-org-js-section-2/
-
remove parts from Schemahttps://wordpress.org/support/topic/remove-parts-from-schema/
-
Remove Person Schemahttps://wordpress.org/support/topic/remove-person-schema-2/
-
Adding Table of Contents in Bulkhttps://wordpress.org/support/topic/adding-table-of-contents-in-bulk/
-
Remove in aioseo-schema datePublished and dateModifiedhttps://wordpress.org/support/topic/remove-in-aioseo-schema-datepublished-and-datemodified/
-
Remove Schema?https://wordpress.org/support/topic/remove-schema-5/
-
How to remove highPrice snippet and show only lowPrice in AIO schemahttps://wordpress.org/support/topic/how-to-remove-highprice-snippet-and-show-only-lowprice-in-aio-schema/
-
Typohttps://wordpress.org/support/topic/typo-52/
-
More elements to Course Type Schemahttps://wordpress.org/support/topic/more-elements-to-course-type-schema/
-
How to change Schema Markup “inlanguage”https://wordpress.org/support/topic/how-to-change-schema-markup-inlanguage-2/
-
Meta Published Time differs from Schema Date Publishedhttps://wordpress.org/support/topic/meta-published-time-differs-from-schema-date-published/
-
we are receiving an FAQ schema errorhttps://wordpress.org/support/topic/we-are-receiving-an-faq-schema-error/
-
Disable localbusiness schemahttps://wordpress.org/support/topic/disable-localbusiness-schema/
-
how to remove schema mark up for specific pagehttps://wordpress.org/support/topic/how-to-remove-schema-mark-up-for-specific-page/
-
AISEO Homepage schema disabledhttps://wordpress.org/support/topic/aiseo-homepage-schema-disabled/
-
How to add structured data (Schema) to the Taxonomies sectionshttps://wordpress.org/support/topic/how-to-add-structured-data-schema-to-the-taxonomies-sections/