Last active
July 23, 2021 08:08
-
-
Save amboutwe/ededa6e74b099060f0080251721a1824 to your computer and use it in GitHub Desktop.
Remove all JSON output by Yoast SEO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/ | |
/* Remove all JSON output by Yoast SEO | |
* Credit: Yoast development team | |
* Documentation: https://developer.yoast.com/schema-documentation/api/ | |
* Last Tested: Apr 16 2019 using Yoast SEO 11.0 on WordPress 5.1.1 | |
*/ | |
add_filter( 'wpseo_json_ld_output', '__return_false' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/ | |
/* Remove JSON output on certain items by Yoast SEO | |
* Credit: Yoast development team | |
* Documentation: https://developer.yoast.com/schema-documentation/api/ | |
* Last Tested: Dec 03 2019 using Yoast SEO 12.6.2 on WordPress 5.3 | |
********* | |
* DIFFERENT POST TYPES | |
* Post: Change 123456 to the post ID | |
* Page: Change is_single to is_page and 123456 to the page ID | |
* Custom Post Type: Change is_single to is_singular and 123456 to the 'post_type_slug' | |
Example: is_singular( 'cpt_slug' ) | |
********* | |
* MULTIPLE ITEMS | |
* Remove 123456 for all items of that type | |
Example: is_single() means all posts | |
* Multiple of the same type can use an array. | |
Example: is_single( array( 123456, 1234567, 12345678 ) ) | |
* Multiple of different types can repeat the if statement | |
*/ | |
add_filter( 'wpseo_json_ld_output', 'yoast_seo_json_remove_partial' ); | |
function yoast_seo_json_remove_partial() { | |
if ( is_single ( 123456 ) ) { | |
return false; | |
} | |
/* Use a second if statement here when needed */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment