Skip to content

Instantly share code, notes, and snippets.

View amboutwe's full-sized avatar

Angi amboutwe

View GitHub Profile
@amboutwe
amboutwe / yoast_seo_breadcrumb_add_woo_shop.php
Last active March 15, 2024 14:55
Multiple examples of how to customize the Yoast SEO breadcrumbs
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Add shop link to the Yoast SEO breadcrumbs for a WooCommerce shop page.
* Credit: https://wordpress.stackexchange.com/users/8495/rjb
* Last Tested: Apr 20 2017 using Yoast SEO 4.6 on WordPress 4.7.3
*/
add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_add_woo_shop_link' );
@amboutwe
amboutwe / yoast_seo_breadcrumb_remove_link.php
Last active April 12, 2024 06:43
These snippets are examples of how you can modify the Yoast SEO breadcrumb visual output. These snippets will not alter the breadcrumb schema output. Please consult the schema documentation to change the breadcrumb schema: https://developer.yoast.com/features/schema/api#to-add-or-remove-graph-pieces
@amboutwe
amboutwe / wordpress_robots_custom.php
Last active March 20, 2024 15:22
Filters and example code for Yoast SEO robots or WP robots.txt
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Replace Disallow with Allow Generated Robots.txt
* Credit: Unknown
* Last Tested: June 09 2020 using WordPress 5.4.1
*/
add_filter('robots_txt','custom_robots');
@amboutwe
amboutwe / yoast_seo_opengraph_change_image_size.php
Last active January 11, 2024 20:48
Code snippet to change or remove OpenGraph output in Yoast SEO. There are multiple snippets in this code.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Change size for Yoast SEO OpenGraph image for all content
* Credit: Yoast Development team
* Last Tested: May 19 2020 using Yoast SEO 14.1 on WordPress 5.4.1
* Accepts WordPress reserved image size names: 'thumb', 'thumbnail', 'medium', 'large', 'post-thumbnail'
* Accepts custom image size names: https://developer.wordpress.org/reference/functions/add_image_size/
*/
@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_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_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_sitemap_exclude_taxonomy.php
Last active July 29, 2018 13:13
Sitemaps: There are two sets of code in this gist, one for a single taxonomy or for multiple taxonomies. Only copy the section you need and replace the taxonomy_slug with the actual name of the taxonomy slug to be excluded.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Exclude One Taxonomy From Yoast SEO Sitemap
* Credit: Yoast KB https://kb.yoast.com/kb/how-to-customize-the-sitemap-index/
* Last Tested: Apr 05 2018 using Yoast SEO 7.2 on WordPress 4.9.5
*********
* Please note that changes will be applied upon next sitemap update.
* To manually refresh the sitemap, please disable and enable the sitemaps.
*/
@amboutwe
amboutwe / yoast_seo_prev_next_change.php
Last active July 7, 2023 19:54
Remove or modify the Yoast SEO prev or next URLs. Only copy the section of code you need.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Change Yoast SEO Prev/Next URL on some pages
* Credit: Yoast Team
* Last Tested: Jun 10 2017 using Yoast SEO 4.9 on WordPress 4.8
*/
add_filter( 'wpseo_next_rel_link', 'custom_change_wpseo_next' );
@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