Skip to content

Instantly share code, notes, and snippets.

Avatar

Angi amboutwe

View GitHub Profile
View yoast_seo_meta_sync_indexable.php
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Sync post meta to Yoast Indexable
* Credit: Yoast team
* Last Tested: Jun 11 2020 using Yoast SEO 14.3 on WordPress 5.4.2
*/
// The ID of the post to modify
$post_id = 1;
View yoast_seo_local_disable_jquery.php
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Disable jquery / JavaScript in Yoast SEO Local
* Credit: Bill Erickson https://www.billerickson.net/
* Last Tested: Unknown
*/
add_filter( 'wpseo_local_load_jquery', '__return_false' );
View yoast_seo_opengraph_add_publish_date_post_types.php
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Enable OpenGraph published and modified dates for all post types
* Credit: Yoast team
* Last Tested: Oct 01 2019 using Yoast SEO 12.2 on WordPress 5.2.3
*/
add_filter('wpseo_opengraph_show_publish_date', '__return_true');
View yoast_seo_sitemap_include_empty_terms.php
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Include empty terms in the sitemap
* Credit: Yoast team
* Last Tested: Mar 22 2019 using Yoast SEO 10.0.1 on WordPress 5.1.1
*/
add_filter('wpseo_sitemap_exclude_empty_terms', '__return_false');
@amboutwe
amboutwe / yoast_seo_disable_single_post.php
Last active Jun 23, 2020
Remove Yoast from front end for a single post or page
View yoast_seo_disable_single_post.php
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yoast from front end for a single post or page
* Credit: Dodinas https://stackoverflow.com/questions/37845968/disable-wordpress-yoast-seo-on-single-page
* Last Tested: Nov 08 2019 using Yoast SEO 12.4 on WordPress 5.2.4
* Note: For version 14+, please use the code here: https://developer.yoast.com/customization/yoast-seo/disabling-yoast-seo
*********
* DIFFERENT POST TYPES
* Post: Change 123456 to the post ID
* Page: Change is_single to is_page and 123456 to the page ID
@amboutwe
amboutwe / yoast_seo_replytocom.php
Last active Jul 29, 2018
By default, Yoast SEO removes `?replytocom` variables from URLs. This can be reversed with the following code.
View yoast_seo_replytocom.php
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Yoast SEO return `?replytocom` variables
* Credit: Yoast development team
* Last Tested: Mar 23 2018 using Yoast SEO 7.1 on WordPress 4.9.4
*/
add_filter( 'wpseo_remove_reply_to_com', '__return_false' );
@amboutwe
amboutwe / yoast_seo_title_change-variable.php
Last active May 20, 2020
Change existing or add custom title or meta template variables
View yoast_seo_title_change-variable.php
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yoast SEO Change existing title or meta template variable
* Credit: Moshe Harush
* https://stackoverflow.com/questions/36281915/yoast-seo-how-to-create-custom-variables
* Last Tested: Unknown
*/
// define the wpseo_replacements callback
function filter_wpseo_replacements( $replacements ) {
View yoast_seo_roles_remove.php
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yoast SEO user roles
* Credit: Yoast Team
* Last Tested: Oct 25 2017 using Yoast SEO 5.7.1 on WordPress 4.8.2
*/
// Remove Yoast `SEO Manager` role
if ( get_role('wpseo_manager') ) {
remove_role( 'wpseo_manager' );
@amboutwe
amboutwe / yoast_seo_title_remove.php
Last active Jun 17, 2020
Yoast SEO title snippets
View yoast_seo_title_remove.php
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yoast SEO Title From All Pages
* Credit: Yoast Team
* Last Tested: Jun 17 2020 using Yoast SEO 14.3 on WordPress 5.4.2
*/
add_filter( 'wpseo_title', '__return_false' );
@amboutwe
amboutwe / yoast_seo_admin_user_remove_social.php
Last active Jan 14, 2020
Remove Yoast SEO Social Profiles From All Users
View yoast_seo_admin_user_remove_social.php
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yoast SEO Social Profiles From All Users
* Credit: Yoast Developers
* Last Tested: May 18 2019 using Yoast SEO 11.2.1 on WordPress 5.2
*/
add_filter('user_contactmethods', 'yoast_seo_admin_user_remove_social');
You can’t perform that action at this time.