Disable Sidebar on Shop Page and Product Category Archives: Call to undefined function x_is_shop()?

Continuing the discussion from Disable sidebar on shop page but enable on product category archives:

I have another website very similar to the original one I opened the discussion for, but instead of disabling the sidebar on just the shop page, I want to disable it on both shop page and category archives.

In the previous discussion, I was given this code:

// No Sidebar in Shop
// =============================================================================
function no_sidebars_allowed($contents) {
  if ( x_is_shop() ) {
    $contents = 'fullwidth';
  }
  
  return $contents;
}
add_filter('x_option_x_layout_content', 'no_sidebars_allowed');
// =============================================================================

I modify it to include this in the check:

if ( x_is_shop() || x_is_product_category() ) {

When I added it to my child theme’s functions.php the website runs into technical difficulties. Upon checking the technical issue email, I see the following:

Error Details

An error of type E_ERROR was caused in line 48 of the file […]/public_html/wp-content/themes/pro-child/functions.php. Error message: Uncaught Error: Call to undefined function x_is_shop() in […]/public_html/wp-content/themes/pro-child/functions.php:48

How is this possible? I have the Pro parent theme and a Pro child theme.

Please let me know what I can do. Thank you!

Hello @jessebrito,

Thanks for writing in!

Please have your code updated and use this instead:

// No Sidebar in Shop
// =============================================================================
function no_sidebars_allowed($contents) {
  if ( is_shop() || is_product_category() || is_product_tag() ) {
    $contents = 'fullwidth';
  }
  
  return $contents;
}
add_filter('x_option_x_layout_content', 'no_sidebars_allowed');
// ============================================================================= 

You can find the rest of the WooCommerce conditional statements here:

Please let us know how it goes.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.