Skip to content

Instantly share code, notes, and snippets.

@deckerweb
Forked from ChrisCree/functions.php
Created April 17, 2017 19:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deckerweb/b5d284ac676dcafac1cfb343a32816ce to your computer and use it in GitHub Desktop.
Save deckerweb/b5d284ac676dcafac1cfb343a32816ce to your computer and use it in GitHub Desktop.
Add the Shop page breadcrumb to single products and archives for WooCommerce pages with the Genesis framework. Code below can be added to your child theme's functions.php file. Then go to Genesis --> Theme Settings and ensure the Breadcrumbs settings for Posts and Archives is enabled. PLEASE NOTE: This code assumes the Genesis Connect for WooCom…
<?php
// Do not copy opening PHP tag above
// Add the Shop page to Genesis breadcrumbs in WooCommerce
// NOTE: Assumes Genesis Connect for WooCommerce plugin is active
add_filter( 'genesis_archive_crumb', 'wsm_prepend_shop_link', 11, 2 );
add_filter( 'genesis_single_crumb', 'wsm_prepend_shop_link', 11, 2 );
function wsm_prepend_shop_link( $crumb, $args ) {
if ( is_singular( 'product' ) || is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) {
$shop_id = wc_get_page_id( 'shop' );
$shop_title = get_the_title( $shop_id );
$prepend = gencwooc_get_crumb_link( get_permalink( $shop_id ), $shop_title, $shop_title, $args['sep'] );
$crumb = $prepend . $crumb;
}
return $crumb;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment