Skip to content

Instantly share code, notes, and snippets.

View amboutwe's full-sized avatar

Angi amboutwe

View GitHub Profile
<?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'
*/
@amboutwe
amboutwe / yoast_seo_title_remove.php
Last active February 17, 2022 14:57
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: Jun 17 2020 using Yoast SEO 14.3 on WordPress 5.4.2
*/
add_filter( 'wpseo_title', '__return_false' );
@amboutwe
amboutwe / yoast_seo_robots_add_sitemap.php
Last active November 2, 2021 13:17
Add the Yoast SEO sitemap index to the WordPress generated robots.txt file.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Add Sitemap Index To Generated Robots.txt
* Credit: Ben https://github.com/retlehs
* Last Tested: Mar 13 2017 using Yoast SEO 4.4 on WordPress 4.7.3
*/
add_action('do_robots', 'custom_robotstxt');
@amboutwe
amboutwe / yoast_seo_json_remove.php
Last active July 23, 2021 08:08
Remove all JSON output by Yoast SEO
<?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' );
@amboutwe
amboutwe / yoast_seo_disable_single_post.php
Last active May 25, 2021 22:39
Remove Yoast from front end for a single post or page
<?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_primary_category_disable.php
Last active May 3, 2021 19:35
Disable Yoast SEO Primary Category Feature
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Disable Yoast SEO Primary Category Feature
* Credit: Yoast development team
* Last Tested: Jan 24 2017 using Yoast SEO 4.1 on WordPress 4.7.1
*/
add_filter( 'wpseo_primary_term_taxonomies', '__return_empty_array' );
@amboutwe
amboutwe / yoast_seo_meta_remove_dates.php
Last active October 5, 2020 08:39
Remove Date Meta Tags Output by Yoast SEO
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Date Meta Tags Output by Yoast SEO
* Credit: Yoast development team
* Last Tested: Apr 09 2019 using Yoast SEO 10.1.3 on WordPress 5.1.1
* For Yoast SEO 14.0 or newer, please see https://yoast.com/help/date-appears-search-results/#h-managing-dates
*/
add_action('wpseo_dc_'.'DC.date.issued', '__return_false'); // Premium versions 5.2 or older
@amboutwe
amboutwe / yoast_seo_breadcrumbs_replace_woocommerce_storefront.php
Last active September 7, 2020 17:28
There are two sets of code in this gist; one for the Twenty Nineteen theme and another for the Storefront theme. These are to be used as an example as you or your developer may need to modify the code depending on your theme and site needs.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Replace WooCommerce Breadcrumbs With Yoast Breadcrumbs
* Credit: Mixed
* Last Tested: Oct 09, 2019 using WooCommerce 3.7.1 with Yoast SEO 12.2 on WordPress 5.2.3
* Theme: Storefront v2.5.3
*/
// Remove WooCommerce Breadcrumbs - Storefront
<?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' );
@amboutwe
amboutwe / yoast_local_label_change_phone_2.php
Last active December 27, 2019 18:03
Change labels for select items in Yoast SEO Local
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Yoast SEO Custom label for Business Phone 2
* Credit: Yoast development team
* Last Tested: Apr 28 2017 using Yoast SEO Local 4.6 on WordPress 4.7.4
*/
add_filter( 'wpseo_local_contact_details', 'yoast_local_label_change_phone_2', 10, 1 );