Home Forums WoodMart support forum How to select header for product in specific product category

How to select header for product in specific product category

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #278077

    serezart
    Participant

    Hi support,

    I made the header selection in a category I specified with your support, with the following code. So, can we make a header selection on the product pages in the category that I have determined?

    I would be glad if you help me, a very important issue.

    Category’s id= 69
    Header’s id= header_626309

    add_filter(
    ‘woodmart_get_current_header_id’,
    function ( $id ) {
    if ( is_product_category() && is_object( get_queried_object() ) ) {
    if ( get_queried_object()->term_id == 69 ) {
    return ‘header_626309’;
    }
    }
    return $id;
    }
    );

    #278189

    Artem Temos
    Keymaster

    Hello,

    You don’t need to use this code since we will add such ability in our Theme Settings in our next update. We recommend you wait for the next week when our 6.0 version will be available.

    Kind Regards

    #278195

    serezart
    Participant

    Hi,

    Thank you for your reply.

    Regards

    #278230

    Artem Temos
    Keymaster

    You are welcome. Let me know if you have any additional questions on this matter.

    #280816

    serezart
    Participant

    Hi support,

    The last released update is really successful, congratulations and thank you. I have a question. I chose a product category from the options presets section and set it up. When I entered this product category, all my settings were applied successfully. However, when I enter a product in this category, the settings are not valid, the general settings are valid. There are 300 products belonging to this category that I mentioned. Do I need to create presets for 300 items one by one? Can I apply the same setting to all products like this main category that I set?

    Thanx

    #280826

    Artem Temos
    Keymaster

    Hello,

    We understand your purpose but there there is no such option at the moment. We will try to add some extra condition option for this in our next update.

    Kind Regards

    #280945

    serezart
    Participant

    Hello,

    It will be very useful if you take action on this subject. So how can I select the header field of the products in the category I specified? I would appreciate it if you could share some code that I can write to the functions.php file.

    Regards.

    #281131

    Artem Temos
    Keymaster

    Try to add the following PHP code snippet to the child theme functions.php file to do this

    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(
    				37,
    				31,
    				88,
    			);
    			foreach ( $terms as $term ) {
    				if ( in_array( $term->term_id, $categories_list, true ) ) {
    					$id = 'header_675505';
    				}
    			}
    		}
    		return $id;
    	}
    );
    #281134

    serezart
    Participant

    Thank you so much! Amazing support.

    Regards.

    #281296

    Artem Temos
    Keymaster

    You are welcome! Feel free to contact us if you have any questions.

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

The topic ‘How to select header for product in specific product category’ is closed to new replies.