Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@amboutwe
Last active April 2, 2022 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amboutwe/ebc7a8b974c2735cdd5aae84035bf65b to your computer and use it in GitHub Desktop.
Save amboutwe/ebc7a8b974c2735cdd5aae84035bf65b to your computer and use it in GitHub Desktop.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Prevent Yoast SEO for adding specific post types to indexables
* Credit: Yoast team
* Last Tested: Jan 18 2021 using Yoast SEO 15.6.2 on WordPress 5.6
* Documented: https://github.com/Yoast/wordpress-seo/blob/trunk/src/helpers/post-type-helper.php#L90
* Common post types: 'post', 'page', 'attachment', 'product'
*/
add_filter('wpseo_indexable_excluded_post_types', 'yoast_exclude_some_custom_post_types');
function yoast_exclude_some_custom_post_types ( $excluded_post_types ) {
$excluded_post_types[] = 'post_type_slug'; // Repeat for each type to exclude
return $excluded_post_types; // Do not remove this line
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment