add_filter( 'aioseo_schema_disable', 'aioseo_disable_schema_for_parent_and_children' );
function aioseo_disable_schema_for_parent_and_children( $disabled ) {
// Only execute this logic on standard WordPress pages
if ( is_page() ) {
global $post;
$parent_page_id = 26489; // 💡 REPLACE WITH YOUR ACTUAL PARENT PAGE ID
// Check if we are viewing the parent page itself
if ( is_page( $parent_page_id ) ) {
return true;
}
// Check if the current page has the target parent page as an ancestor
$ancestors = get_post_ancestors( $post->ID );
if ( in_array( $parent_page_id, $ancestors ) ) {
return true;
}
}
return $disabled;
}
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.