I’m trying to remove the Yoast schema on posts and pages in my functions.php. But, one will work but together they won’t. Any way to get this to work together?
Here’s what I have tried so far:
//Remove All Schema on post
add_filter( 'wpseo_json_ld_output', 'yoast_seo_json_remove_partial_post' );
function yoast_seo_json_remove_partial_post() {
if ( is_single ( [ 2544, 2743 ] ) ) {
return false;
}
}
//Remove Schema on Page
add_filter( 'wpseo_json_ld_output', 'yoast_seo_json_remove_partial_page' );
function yoast_seo_json_remove_partial_page () {
if ( is_page ( [ 15, ] ) ) {
return false;
}
}
I need to remove them from any page I want if possible. Thanks for any help with this.
2
Answers
You can just use OR operator for conditional
Please remove the , from the code below. It might terminate the code
Alternatively, instead of using two functions, please create one and combine both conditions using the logical OR operator.