Home Forums WoodMart support forum custom header code

custom header code

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #402766

    loralora
    Participant

    Hello

    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;
    	}
    );
    #402787

    Hello,

    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

    #402919

    loralora
    Participant

    Did I understand correctly that for product pages I should use “Single post form term” and for category pages – “Term ID”?

    #402921

    loralora
    Participant

    1. 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?

    #403745

    Hello,

    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

    #403773

    loralora
    Participant

    Hello,
    Thanks
    Topic Closed.

    Best Regards.

    #404154

    You are welcome! We are here to help.

    Wish you a wonderful day!

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘custom header code’ is closed to new replies.