Skip to content

Instantly share code, notes, and snippets.

@braddalton
Created May 8, 2019 09:18
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 braddalton/ffbccbacb81785895f002077128dffef to your computer and use it in GitHub Desktop.
Save braddalton/ffbccbacb81785895f002077128dffef to your computer and use it in GitHub Desktop.
Yoast SEO Genesis https://wp.me/p1lTu0-ith
add_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
/**
* Display Breadcrumbs above the Loop. Concedes priority to popular breadcrumb
* plugins.
*
* @since 1.0.0
*
* @return void Return early if Genesis settings dictate that no breadcrumbs should show in current context.
*/
function genesis_do_breadcrumbs() {
if (
( is_single() && ! genesis_get_option( 'breadcrumb_single' ) ) ||
( is_page() && ! genesis_get_option( 'breadcrumb_page' ) ) ||
( is_404() && ! genesis_get_option( 'breadcrumb_404' ) ) ||
( is_attachment() && ! genesis_get_option( 'breadcrumb_attachment' ) ) ||
( ( '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_archive() || is_search() ) && ! genesis_get_option( 'breadcrumb_archive' ) )
) {
return;
}
$config = genesis_get_config( 'breadcrumbs' );
if ( function_exists( 'bcn_display' ) ) {
echo $config['prefix'];
bcn_display();
echo $config['suffix'];
} elseif ( function_exists( 'breadcrumbs' ) ) {
breadcrumbs();
} elseif ( function_exists( 'crumbs' ) ) {
crumbs();
} elseif ( class_exists( 'WPSEO_Breadcrumbs' ) && genesis_get_option( 'breadcrumbs-enable', 'wpseo_titles' ) ) {
yoast_breadcrumb( $config['prefix'], $config['suffix'] );
} elseif ( function_exists( 'yoast_breadcrumb' ) && ! class_exists( 'WPSEO_Breadcrumbs' ) ) {
yoast_breadcrumb( $config['prefix'], $config['suffix'] );
} else {
genesis_breadcrumb( $config );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment