Home › Forums › WoodMart support forum › custom header code
custom header code
- This topic has 6 replies, 2 voices, and was last updated 2 years, 4 months ago by Elise Noromit.
-
AuthorPosts
-
September 11, 2022 at 3:05 pm #402766
loraloraParticipantHello
Can you please tell me if this code still works?
I used in the enumeration array the ids of the categories for which I need to set a custom header for products and categories (other than the default one).
eg: default header for female. custom header for male.But for some reason it seems to me that it does not work. I still end up with the default header in male categories.
add_filter( 'woodmart_get_current_header_id', function( $id ) { if ( is_product() ) { global $post; $terms = get_the_terms( $post->ID, 'product_cat' ); $categories_list = array( 233, 1889, 1875, 1891, 1887, 1886, 1893, 1894 ); foreach ( $terms as $term ) { if ( in_array( $term->term_id, $categories_list, true ) ) { $id = 'header_931338'; } } } return $id; } ); add_filter( 'woodmart_get_current_header_id', function( $id ) { if ( is_product_category() ) { global $archive; $terms = get_the_terms( $post->ID, 'product_cat' ); $categories_list = array( 233, 1889, 1875, 1891, 1887, 1886, 1893, 1894 ); foreach ( $terms as $term ) { if ( in_array( $term->term_id, $categories_list, true ) ) { $id = 'header_931338'; } } } return $id; } );
September 11, 2022 at 10:16 pm #402787
Elise NoromitMemberHello,
Please remove the code and use the theme preset to set the custom header for every product category. Find our documentation tutorial about this here: https://xtemos.com/docs-topic/theme-settings-presets/
If you have any questions please feel free to contact us.
Best Regards
September 12, 2022 at 1:56 pm #402919
loraloraParticipantDid I understand correctly that for product pages I should use “Single post form term” and for category pages – “Term ID”?
September 12, 2022 at 2:01 pm #402921
loraloraParticipant1. Can you add the ability to select an array in the update? for example, for “Single post form term”, specify the enumeration of the id array?, and not the selection by 1 value.
2. is it possible to select 1 value for all categories and subcategories?
For example, if ID 233 is the category “Men” (contains 40 categories of 2nd level and subcategories of 3rd level) – the choice of 1 ID 233 worked for all categories and subcategories of the parent category?
September 13, 2022 at 3:24 pm #403745
Elise NoromitMemberHello,
You need to add conditions for every category. As the result, when you set the preset for the parent category, the children categories would inherit.
If you have any questions please feel free to contact us.
Best Regards
September 13, 2022 at 3:52 pm #403773
loraloraParticipantHello,
Thanks
Topic Closed.Best Regards.
September 14, 2022 at 1:22 am #404154
Elise NoromitMemberYou are welcome! We are here to help.
Wish you a wonderful day!
-
AuthorPosts
The topic ‘custom header code’ is closed to new replies.
- You must be logged in to create new topics. Login / Register