Skip to content

Instantly share code, notes, and snippets.

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 djvdorp/01df2442cd72152ccc8b05e66ffd0e85 to your computer and use it in GitHub Desktop.
Save djvdorp/01df2442cd72152ccc8b05e66ffd0e85 to your computer and use it in GitHub Desktop.
Yoast SEO title snippets
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yoast SEO Title From All Pages
* Credit: Yoast Team
* Last Tested: Aug 11 2017 using Yoast SEO 5.2 on WordPress 4.8.1
*/
add_filter( 'wpseo_title', '__return_false' );
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yoast SEO Title From An Individual Post/Page/CPT
* Credit: Yoast Team
* Last Tested: Aug 11 2017 using Yoast SEO 5.2 on WordPress 4.8.1
*********
* 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
* 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_title', 'remove_one_wpseo_title' );
function remove_one_wpseo_title() {
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