Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beans_breadcrumb() should check for false return from get_post_type_archive_link() #206

Open
iCaspar opened this issue Apr 5, 2018 · 3 comments

Comments

@iCaspar
Copy link
Contributor

iCaspar commented Apr 5, 2018

@see https://community.getbeans.io/discussion/wrong-woocommerce-breadcrumbs/ for initial report.

WooCommerce Products have no archive link. So we end up with an entry in $breadcrumbs like

[0] => 'Products'

where [0] should be a url.

Presumably this would be the case for any CPT object for which has_archive is not set or false. Checking for it is easy enough, but what to do in these events?

We probably ought to implement a check for WooCommerce, since this will be a common case. Beyond that some things that come to mind:

  1. We could attempt to find taxonomies/terms belonging to the CPT.
  2. We could insert a placeholder key and then output the PostType label without linking.
  3. We could just bail out of that iteration and leave that bit of the breadcrumb out, since it's essentially inaccessible for a visitor anyway.
@tonamphong
Copy link

Hi there,
I found a solution for this case
Add code to function.php (child theme)

add_action( 'after_setup_theme', 'woocommerce_support' ); function woocommerce_support() { add_theme_support( 'woocommerce' ); add_theme_support( 'wc-product-gallery-zoom' ); add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' ); }

Woo will add their breadcrumb by default on all shop pages.

To remove theme breadcrumbs on shop pages(avoid duplicate), just add

add_action ('wp' , 'woo_dup_disable_breadcrumb'); function woo_dup_disable_breadcrumb() { if ( is_woocommerce() ) { // Remove the breadcrumb. add_filter( 'beans_pre_load_fragment_breadcrumb', '__return_true' ); } }

It works, however, if you disable the woocommerce plugin, you need to remove the code above in function.php file.
I'm looking for the function that working if woo is disabled but no luck. Tried this solution https://docs.woocommerce.com/document/query-whether-woocommerce-is-activated/ but theme breadcrumb still appear with Woocommerce breadcrumb on shop pages.

@hellofromtonya
Copy link
Contributor

@iCaspar Where do we stand on this issue?

@hellofromtonya
Copy link
Contributor

I'm thinking we can roll this issue into the Beans WooCommerce plugin, i.e. yet to be developed. Let's target for that plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants