Tagged: custom sidebar, wooocommerce
-
AuthorPosts
-
December 11, 2017 at 11:29 am #887289
Hello,
I use:add_filter( ‘avf_custom_sidebar’, ‘enfold_customization_custom_sidebar’, 10, 1 );
function enfold_customization_custom_sidebar( $custom_sidebar ) {
if ( is_product_category( ‘custom’ ) ) { $custom_sidebar = ‘custom’; }
return $custom_sidebar;
}To get custom sidebars on category pages, but this doesn’t work for sub-category pages.
Any ideas how this could be possible?
December 11, 2017 at 2:32 pm #887418Hey Wolf,
Here is a thread for you to consider
https://wordpress.org/support/topic/is_product_category-and-all-subcategories/If you need further assistance please let us know.
Best regards,
VictoriaDecember 11, 2017 at 2:53 pm #887431I don’t really understand that.
December 11, 2017 at 4:18 pm #887484Hi Wolf,
Here is the code you can put in your funtions.php
add_filter( 'avf_custom_sidebar', 'enfold_customization_custom_sidebar', 10, 1 ); function enfold_customization_custom_sidebar( $custom_sidebar ) { if ( is_product_category( 'custom' ) || cat_is_ancestor_of(your custom category id, get_queried_object()->term_id ) ) { $custom_sidebar = ‘custom’; } return $custom_sidebar; }
If you need further assistance please let us know.
Best regards,
VictoriaDecember 11, 2017 at 5:29 pm #887516I’m sorry Victoria, but I need a little more explanation with this.
What is this supposed to do? If it is supposed to give category pages and sub-category pages the same sidebar I think it doesn’t work. But I don’t really know which parts of this code should be replaced. So I could be wrong
add_filter( ‘avf_custom_sidebar’, ‘enfold_customization_custom_sidebar’, 10, 1 );
function enfold_customization_custom_sidebar( $custom_sidebar ) {
if ( is_product_category( ‘custom’ ) || cat_is_ancestor_of(your custom category id, get_queried_object()->term_id ) ) { $custom_sidebar = ‘custom’; }
return $custom_sidebar;
}December 12, 2017 at 11:41 am #887847Hi Wolf,
This code is supposed to do what you need when you insert your custom category id instead of text.
Best regards,
VictoriaDecember 13, 2017 at 3:17 pm #888379that didn’t help. But it is fixed now, you can close this
December 13, 2017 at 4:47 pm #888439Hi Wolf,
Glad you got it working for you! :)
If you need further assistance please let us know.
Best regards,
VictoriaJanuary 8, 2018 at 3:18 pm #894722Hello Victoria,
I have a new question about this problem.
January 8, 2018 at 4:18 pm #894751Hi Wolf,
Then in the function, you need to check for the subcategory and depending on the subcategory assign a different sidebar, all in this function, not adding the same function twice, which breaks your website.
Best regards,
VictoriaJanuary 8, 2018 at 4:52 pm #894769I don’t have the knowledge to do that. Is there a recommended plugin for this.
January 8, 2018 at 7:50 pm #894880Hi Wolf,
You might want to hire a freelancer to do it for you.
Or you can have a look at this article
http://www.wpbeginner.com/wp-themes/display-different-sidebar-for-each-post-and-page-for-wordpress/If you need further assistance please let us know.
Best regards,
VictoriaJanuary 9, 2018 at 9:46 am #895153Thank you for the help Victoria, but I figured it out.
I use one sidebar on all subcategory pages. Because filter on product property are only active if you have a product in the category. This way it works.January 10, 2018 at 10:54 pm #895843Hi,
Glad we could help!
To know more about enfold features please check – http://kriesi.at/documentation/enfold/
Thank you for using Enfold :)Best regards,
Basilis -
AuthorPosts
- The topic ‘Custom sidebar on sub-category pages – Woocommerce’ is closed to new replies.