Home Forums WoodMart support forum different header for different parent categories

different header for different parent categories

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #284366

    loralora
    Participant

    Hi, 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?

    #284414

    Hello,

    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 Regards

    #284749

    loralora
    Participant

    thanks 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.

    #284821

    Hello,

    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

    #285085

    loralora
    Participant

    Hi, 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 …

    #285412

    Hello,

    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

    #285496

    loralora
    Participant

    Thank 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

    #285809

    Hello,

    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

    #285857

    loralora
    Participant

    It is wonderful! I will wait for it
    thank you

    #286050

    You are welcome! If you have any questions please feel free to contact us.

    Best Regards

    #286078

    loralora
    Participant

    Yes, 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 :))

    #286708

    Hello,

    We will need 4-6 weeks for this feature.

    Best Regards

    #286730

    loralora
    Participant

    this is very cool, thank you again. I have no more questions on this topic.

    #286905

    You are welcome! If you have any questions please feel free to contact us.

    Best Regards

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

The topic ‘different header for different parent categories’ is closed to new replies.