Skip to content

Instantly share code, notes, and snippets.

@AlphaBlossom
Last active August 29, 2015 14:03
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 AlphaBlossom/1027fdf9da59a829c31d to your computer and use it in GitHub Desktop.
Save AlphaBlossom/1027fdf9da59a829c31d to your computer and use it in GitHub Desktop.
Genesis Fix for Yoast SEO Plugin Disabling Genesis Breadcrumbs
elseif ( function_exists( 'yoast_breadcrumb' ) ) {
yoast_breadcrumb( '<div>', '</div>' );
}
/**
* If Yoast SEO breadcrumbs are not enabled,
* replace default Genesis breadcrumbs with modified Genesis breadcrumbs
* edited to fix issue with Yoast Breadcrumbs removing Genesis breadcrumbs
* even when Yoast breadcrumbs are not enabled.
*
* If Yoast breadcrumbs are enabled, no need to replace default Genesis breadcrumbs
*
* http://wordpress.org/support/topic/breadcrumbs-function-exists-even-if-toggled-off?replies=4#post-5352313
*
* @author AlphaBlossom / Tony Eppright
* @link http://www.alphablossom.com
*
*/
add_action('get_header','abte_genesis_breadcrumbs_over_yoast_breadcrumbs');
function abte_genesis_breadcrumbs_over_yoast_breadcrumbs() {
$wpseo_crumbs = get_option( 'wpseo_internallinks' );
if ( function_exists( 'yoast_breadcrumb' ) && $wpseo_crumbs[ 'breadcrumbs-enable' ] !== true ) {
// When Yoast SEO is activated, Genesis crumbs disappear
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
// Replace default genesis breadcrumbs with modified breadcrumbs to remove Yoast breadcrumbs
// Replace genesis_before_loop with another hook if you want to move breadcrumb locations
add_action( 'genesis_before_loop', 'abte_genesis_do_breadcrumbs' );
}
}
/**
* Display Breadcrumbs above the Loop. Concedes priority to popular breadcrumb
* plugins.
*
* @since 0.1.6
*
* @return null Return null if a popular breadcrumb plugin is active
*/
function abte_genesis_do_breadcrumbs() {
if (
( ( 'posts' === get_option( 'show_on_front' ) && is_home() ) && ! genesis_get_option( 'breadcrumb_home' ) ) ||
( ( 'page' === get_option( 'show_on_front' ) && is_front_page() ) && ! genesis_get_option( 'breadcrumb_front_page' ) ) ||
( ( 'page' === get_option( 'show_on_front' ) && is_home() ) && ! genesis_get_option( 'breadcrumb_posts_page' ) ) ||
( is_single() && ! genesis_get_option( 'breadcrumb_single' ) ) ||
( is_page() && ! genesis_get_option( 'breadcrumb_page' ) ) ||
( ( is_archive() || is_search() ) && ! genesis_get_option( 'breadcrumb_archive' ) ) ||
( is_404() && ! genesis_get_option( 'breadcrumb_404' ) ) ||
( is_attachment() && ! genesis_get_option( 'breadcrumb_attachment' ) )
)
return;
if ( function_exists( 'bcn_display' ) ) {
echo '<div class="breadcrumb" itemprop="breadcrumb">';
bcn_display();
echo '</div>';
}
/*
* Remove Yoast function if Yoast function is not enabled
* See abte_genesis_breadcrumbs_over_yoast_breadcrumbs() function above
*
elseif ( function_exists( 'yoast_breadcrumb' ) ) {
yoast_breadcrumb( '<div class="breadcrumb">', '</div>' );
}
*/
elseif ( function_exists( 'breadcrumbs' ) ) {
breadcrumbs();
}
elseif ( function_exists( 'crumbs' ) ) {
crumbs();
}
else {
genesis_breadcrumb();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment