This code snippet disables the schema generated by the All in One SEO (AIOSEO) plugin on singular posts or pages (is_singular()) and archive pages (is_archive()). By hooking into the aioseo_schema_disable filter, the function checks the type of page being loaded. If it matches a singular post or archive page, the function returns true, effectively turning off the schema markup for these page types.
This snippet needs to be inserted into the functions.php file of your child theme.
add_filter( 'aioseo_schema_disable', 'aioseo_disable_schema_all_pages' );
function aioseo_disable_schema_all_pages( $disabled ) {
if ( is_singular() || is_archive() ) {
return true;
}
return $disabled;
}
Snippet to disable schema in All in One SEO plugin for specific pages by their IDs:
add_filter( 'aioseo_schema_disable', 'aioseo_disable_schema_for_specific_pages' );
function aioseo_disable_schema_for_specific_pages( $disabled ) {
$disable_for_pages = array( 10, 25, 42 ); // Replace with the desired page IDs
if ( is_page( $disable_for_pages ) ) {
return true;
}
return $disabled;
}
Snippet to disable schema in All in One SEO plugin for specific posts by their IDs:
add_filter( 'aioseo_schema_disable', 'aioseo_disable_schema_for_specific_posts' );
function aioseo_disable_schema_for_specific_posts( $disabled ) {
$disable_for_posts = array( 12, 34, 56 ); // Replace with the desired post IDs
if ( is_single( $disable_for_posts ) ) {
return true;
}
return $disabled;
}
Leave a Reply