phpwordpressschemayoast

Any way to get two functions to work on the same request?


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.


Solution

  • You can just use OR operator for conditional

    add_filter( 'wpseo_json_ld_output', function( $default ) {
    
        if ( is_single ( [ 2544, 2743  ] ) || is_page ( 15 ) )
            return false;
    
        return $default;
    });