Home Forums WoodMart support forum Assigning a header to a product depending on the category it is in Reply To: Assigning a header to a product depending on the category it is in

#171236

Artem Temos
Keymaster

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