Skip to content

Instantly share code, notes, and snippets.

@jamiemitchell
Forked from ChrisCree/functions.php
Created November 4, 2018 07:47
Show Gist options
  • Save jamiemitchell/b4517d4396204e25eba7a399139bf0e7 to your computer and use it in GitHub Desktop.
Save jamiemitchell/b4517d4396204e25eba7a399139bf0e7 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