This will work with product categories out of the box. While technically it could be filtered to work with products, they are not hierarchical which would not make much of a menu.
If you add the following filter to your active theme’s functions.php file this will display all categories on the home page.
Everything is good except for one page on my site:
Here, the menu on mobile does not collapse as you can see. To get this to show up on the Shop page, is added ‘ || is_shop ‘ to the function you gave me to get it to show up on the homepage. It shows up and seems to be ok on desktop but not so on mobile. Any thoughts on how to rectify this?
While I don’t see the menu on the shop page (I assume you removed it for now). I do see a bunch of JavaScript errors on that page which are not related to this plugin.
The errors appear to be from Storefront Pro, and some signup forms plugin. I also see a reference to a broken jQuery URL.
Until these JavaScript errors are fixed this menu’s accordion functionality will not work.
Humm … thanks for your response. I did not move the menu. It has never showed up on the shop page, although I would like it to. And, I do not see any javascript errors at all on the shop page?
There are no javascript errors in the console so not sure where you are seeing this?
Sorry for all these emails .. but it is late here and I am going to get some sleep. However, just found perhaps a clue. I had the console open and went through all my pages, or at least a bunch of them. No errors. However, while the console was open, the category menu and the price filter worked fine. Close the console and it stopped working again. Perhaps a loading issue and the console maybe delays something long enough to allow everything to load.
Can you confirm the widget has been added to the same sidebar as the woocommerce price filter widget? Your suggested code is correct to make it show up on the shop page.
It sounds like you may have a browser cache issue preventing things from working. There is an option that allows disabling cache when the console is open which may explain why it only works when open. Does it work if you clear your browser cache?
Here are the errors I see in the console on the shop page but these will not prevent the widget from showing up.
price-slider.min.js?ver=3.3.4:1Uncaught TypeError: e(…).slider is not a function at r (price-slider.min.js?ver=3.3.4:1) at HTMLDocument.<anonymous> (price-slider.min.js?ver=3.3.4:1) at i (jquery.js?ver=1.12.4:2) at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2) at Function.ready (jquery.js?ver=1.12.4:2) at HTMLDocument.K (jquery.js?ver=1.12.4:2)
public.js?ver=5.6.2:176Uncaught TypeError: window.sfproProductImageFlip is not a function at HTMLDivElement.callback (public.js?ver=5.6.2:176) at HTMLDivElement.<anonymous> (jquery.jscroll.min.js?ver=5.6.2:17) at HTMLDivElement.<anonymous> (jquery.js?ver=1.12.4:4) at Function.each (jquery.js?ver=1.12.4:2) at a.fn.init.each (jquery.js?ver=1.12.4:2) at Object.<anonymous> (jquery.js?ver=1.12.4:4) at i (jquery.js?ver=1.12.4:2) at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2) at y (jquery.js?ver=1.12.4:4) at XMLHttpRequest.c (jquery.js?ver=1.12.4:4)
The ability to display the widget on every page the sidebar is displayed (such as shop page or homepage) is now part the PRO plugin version 3.1.0
For finer control you may still use the above filters or a plugin from the WordPress community which allows specifying pages a widget or sidebar should display. As long as “Display on every page” is checked in the widget, this plugin will honor any location settings from other WordPress plugins.
Humm … those Javascript errors seem to be related to functionality I am not using on the site. And still, after clearing cache I do not see errors. Everything comes back as OK.
Would like your opinion on the following. Bear with me here. This might be a bit long.
I am still trying to track down this issue with the MailChimp for WooCommerce plugin. I had actually narrowed it down to the Storefront Pro plugin and the MailChimp plugin not working together. On a whim, though, I removed the filter by price widget and then activated your plugins, Storefront Pro AND the MailChimp plugin and all is fine.
Do you think there is any chance of a conflict between your plugins and the Filter By Category widget? All this seems to revolve around these four elements: Filter By Price Widget, Advanced Sidebar widget, Storefront Pro and MailChimp.
Dave
Any opinions or ideas gratefully accepted. I am running out of time before launch and would hate to delay.
It’s certainly possible that your issue is being caused by the “Filter By Category widget”. Sometimes other widgets/plugins will steal the global state and break conditionals and variables.
Where does this “Filter By Category widget” come from? Another plugin, a theme? If I can add it to a test site, I can look and see if there is a conflict.
I’m sorry. It is not the Filter by Category Widget….it is the Filter By Price widget that comes with WooCommerce. If you could test it and see if there is any conflict, at least we would know.
On another note, is it possible to add your widget to the 404.php page for the theme?
I have confirmed there is no conflict with the “Filter By Price” widget.
You may add the widget to any page you would like including the 404 page. Simply check the “Display on every page” option in the widget and add it to whatever sidebars you would like.
If your theme does not support a sidebar on the 404.php template, you may register one using standard WordPress practices.
This will work with product categories out of the box. While technically it could be filtered to work with products, they are not hierarchical which would not make much of a menu.
If you add the following filter to your active theme’s functions.php file this will display all categories on the home page.
add_filter( 'advanced-sidebar-menu/menus/category/is-displayed', '__return_true' );
add_filter( 'advanced_sidebar_menu_category_ids', 'include_all_parent_terms', 1, 4 );
function include_all_parent_terms( $term_ids, $args, $instance, $object ) {
if( is_home() || is_front_page() ) {
return get_terms( array(
'parent' => 0,
'fields' => 'ids',
'taxonomy' => $object->get_taxonomy(),
'hide_empty' => true,
) );
}
return array();
}
Cheers
However, this seems to stop display on any other pages and also seems to change the styling somehow?
If you change the filters to this it will display on the homepage and not change any functionality any where else.
add_filter( 'advanced-sidebar-menu/menus/category/is-displayed', '__return_true' );
add_filter( 'advanced_sidebar_menu_category_ids', 'include_all_parent_terms', 1, 4 );
function include_all_parent_terms( $term_ids, $args, $instance, $object ) {
if( is_home() || is_front_page() ) {
return get_terms( array(
'parent' => 0,
'fields' => 'ids',
'taxonomy' => $object->get_taxonomy(),
'hide_empty' => true,
) );
}
return $term_ids;
}
Once you have this displayed on the homepage I can help you adjust your theme styles. Currently they have a margin or something between lists.
Hi Dave,
While I don’t see the menu on the shop page (I assume you removed it for now). I do see a bunch of JavaScript errors on that page which are not related to this plugin.
The errors appear to be from Storefront Pro, and some signup forms plugin. I also see a reference to a broken jQuery URL.
Until these JavaScript errors are fixed this menu’s accordion functionality will not work.
Humm … thanks for your response. I did not move the menu. It has never showed up on the shop page, although I would like it to. And, I do not see any javascript errors at all on the shop page?
There are no javascript errors in the console so not sure where you are seeing this?
Sorry for all these emails .. but it is late here and I am going to get some sleep. However, just found perhaps a clue. I had the console open and went through all my pages, or at least a bunch of them. No errors. However, while the console was open, the category menu and the price filter worked fine. Close the console and it stopped working again. Perhaps a loading issue and the console maybe delays something long enough to allow everything to load.
Can you confirm the widget has been added to the same sidebar as the woocommerce price filter widget? Your suggested code is correct to make it show up on the shop page.
It sounds like you may have a browser cache issue preventing things from working. There is an option that allows disabling cache when the console is open which may explain why it only works when open. Does it work if you clear your browser cache?
Here are the errors I see in the console on the shop page but these will not prevent the widget from showing up.
The ability to display the widget on every page the sidebar is displayed (such as shop page or homepage) is now part the PRO plugin version 3.1.0
For finer control you may still use the above filters or a plugin from the WordPress community which allows specifying pages a widget or sidebar should display. As long as “Display on every page” is checked in the widget, this plugin will honor any location settings from other WordPress plugins.
Humm … those Javascript errors seem to be related to functionality I am not using on the site. And still, after clearing cache I do not see errors. Everything comes back as OK.
Hi Matt,
Would like your opinion on the following. Bear with me here. This might be a bit long.
I am still trying to track down this issue with the MailChimp for WooCommerce plugin. I had actually narrowed it down to the Storefront Pro plugin and the MailChimp plugin not working together. On a whim, though, I removed the filter by price widget and then activated your plugins, Storefront Pro AND the MailChimp plugin and all is fine.
Do you think there is any chance of a conflict between your plugins and the Filter By Category widget? All this seems to revolve around these four elements: Filter By Price Widget, Advanced Sidebar widget, Storefront Pro and MailChimp.
Dave
Any opinions or ideas gratefully accepted. I am running out of time before launch and would hate to delay.
It’s certainly possible that your issue is being caused by the “Filter By Category widget”. Sometimes other widgets/plugins will steal the global state and break conditionals and variables.
Where does this “Filter By Category widget” come from? Another plugin, a theme? If I can add it to a test site, I can look and see if there is a conflict.
I’m sorry. It is not the Filter by Category Widget….it is the Filter By Price widget that comes with WooCommerce. If you could test it and see if there is any conflict, at least we would know.
On another note, is it possible to add your widget to the 404.php page for the theme?
Dave
Hi Dave,
I have confirmed there is no conflict with the “Filter By Price” widget.
You may add the widget to any page you would like including the 404 page. Simply check the “Display on every page” option in the widget and add it to whatever sidebars you would like.
If your theme does not support a sidebar on the 404.php template, you may register one using standard WordPress practices.
Here is a good tutorial on how to do so.