Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save taotiwordpress/94f02d211eed74bdd37506da3aea44c5 to your computer and use it in GitHub Desktop.
Save taotiwordpress/94f02d211eed74bdd37506da3aea44c5 to your computer and use it in GitHub Desktop.
Yoast SEO Customizations
<?php
/**
* Customize Yoast SEO Breadcrumbs
*
* 1. Remove the 'Home' Link from Yoast SEO Breadcrumbs
* This 'starts' Breadcrumbs at the 2nd level.
* 2. Remove the 'current page' from the link for 'Example'.
*
* @param array $links of Yoast SEO breadcrumb links.
* @return array $links sends back the updated links.
*/
function wpseo_remove_home_breadcrumb( $links ) {
// Remove the Homepage.
if ( ! is_front_page() && home_url('/') === $links[0]['url'] ) {
array_shift( $links );
}
// Remove 'current page' for 'Example' post type.
// $current_post_type = get_post_type( get_the_ID() );
// if ( 1 < sizeof( $links ) && 'example' === $current_post_type ) {
// array_pop( $links );
// }
return $links;
}
add_filter( 'wpseo_breadcrumb_links', 'wpseo_remove_home_breadcrumb' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment