Home › Forums › WoodMart support forum › different header for different parent categories
different header for different parent categories
- This topic has 13 replies, 2 voices, and was last updated 3 years, 7 months ago by Elise Noromit.
-
AuthorPosts
-
April 19, 2021 at 3:10 pm #284366
loraloraParticipantHi, How do I implement different header for different parent categories? For example, so that for the category Toys, Clothes, Garden: if I am in the Garden category, then it would be possible to show in the “Header bottom” the output of subcategories of only this category. For example, “rake”, “novelties for the gardener”, and so on. But when switching to the category Toys – Khedr changed automatically and already in its “Header bottom” it would be possible to display all the subcategories associated with toys?
Can this be done somehow in a child theme?
April 19, 2021 at 7:40 pm #284414
Elise NoromitMemberHello,
Please create a header for each category.
Then try to add the following PHP code snippet to the child theme functions.php file to do this. Replace ids 10 and 11 with your categories ids and header_576762 with header ids.
add_filter( 'woodmart_get_current_header_id', function ( $id ) { if ( is_product_category() && is_object( get_queried_object() ) ) { if ( get_queried_object()->term_id == 10 ) { return 'header_576762'; } elseif ( get_queried_object()->term_id == 11 ) { return 'header_496420'; } } return $id; } );
If you have any questions please feel free to contact us.
Best RegardsApril 20, 2021 at 4:57 pm #284749
loraloraParticipantthanks a lot for the code, i pasted it. I decided to check on two parent categories – Lighting and Furniture. It does not work well, please watch the video. Headers are not displayed when filtering by your widget, only if you click under the title. And the header does not return to the main one if you go to a category for which the header is not set in the code (which you sent).
I was doing a test on a production site and on a staging site. Video from the intermediate. On a production site, each parent category also has child categories.
April 20, 2021 at 10:19 pm #284821
Elise NoromitMemberHello,
Sorry, try this one:
add_filter( 'wd_get_current_header_id', function ( $id ) { if ( is_product_category() && is_object( get_queried_object() ) ) { if ( get_queried_object()->term_id == 10 ) { return 'header_576762'; } elseif ( get_queried_object()->term_id == 11 ) { return 'header_496420'; } } return $id; } );
Let me know if does not work, we have recently changed the theme code considerably, there may be issues. We will give the valid one.
Best Regards
April 21, 2021 at 12:50 pm #285085
loraloraParticipantHi, thanks, but unfortunately it doesn’t help. The header still does not appear on the category pages and their child categories.
Did I understand correctly that this function can also display the desired header in the product card, if it belongs to a given category?
I gave you the rights of administrator and dsotup in ftp on the test site, please see what is wrong …
April 22, 2021 at 8:22 am #285412
Elise NoromitMemberHello,
I have checked with our dev team and they say this snippet would not work for some time, we will add the option in the preset option.
Best Regards
April 22, 2021 at 10:28 am #285496
loraloraParticipantThank you, please clarify, as I understand it, if I understand correctly due to the difficulties of translation (English-Russian) – this function will be added to the theme settings, with the next update?
Will it be accessible from the settings? And if it will be possible to set a different header for categories and subcategories and subcategories with categories, will it be possible to set a different header for products that are in this category?
For example: Category “Feminine” – with all subcategories – header 1, and all products in the category feminine – header 1.
The male category with all subcategories is head 2 and all products in the male category are head 1.So? This opportunity would be just awesome!
thanks for the answer
April 23, 2021 at 7:35 am #285809
Elise NoromitMemberHello,
Yes, we will add the option to set the different headers for parent/child categories and products.
If you have any questions please feel free to contact us.
Best Regards
April 23, 2021 at 9:27 am #285857
loraloraParticipantIt is wonderful! I will wait for it
thank youApril 23, 2021 at 5:30 pm #286050
Elise NoromitMemberYou are welcome! If you have any questions please feel free to contact us.
Best Regards
April 23, 2021 at 8:11 pm #286078
loraloraParticipantYes, I have one more question on the topic – when do you think there will be a new version of the Woodmart theme, with the addition of this function? how long to wait?
thank you very very very very much :))
April 26, 2021 at 10:16 am #286708
Elise NoromitMemberHello,
We will need 4-6 weeks for this feature.
Best Regards
April 26, 2021 at 11:10 am #286730
loraloraParticipantthis is very cool, thank you again. I have no more questions on this topic.
April 26, 2021 at 7:35 pm #286905
Elise NoromitMemberYou are welcome! If you have any questions please feel free to contact us.
Best Regards
-
AuthorPosts
The topic ‘different header for different parent categories’ is closed to new replies.
- You must be logged in to create new topics. Login / Register