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

    Hi,
    I am using products slider.
    Is it possible to display only featured products?

    #556721

    Shalom!

    Can you please add a new product category and choose to display only those products on your product slider?

    Cheers!
    Yigit

    #556916

    Hi,

    It may be a good idea but then I will have another category in my shop page.
    If I can hide this category from shop page it can be useful.

    #557040

    Hi!

    Yes, you can hide. Please post the link to your website after adding a new category (and point it out please) and we will help you hide it

    Cheers!
    Yigit

    #557056

    Here it is.
    Can you please post the explanation how did you do it?

    #557059

    Hey!

    Please add following code to Functions.php file in Appearance > Editor

    add_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
    
    function custom_pre_get_posts_query( $q ) {
    
    	if ( ! $q->is_main_query() ) return;
    	if ( ! $q->is_post_type_archive() ) return;
    	
    	if ( ! is_admin() && is_shop() ) {
    
    		$q->set( 'tax_query', array(array(
    			'taxonomy' => 'product_cat',
    			'field' => 'slug',
    			'terms' => array( 'knives' ), // Don't display products in the knives category on the shop page
    			'operator' => 'NOT IN'
    		)));
    	
    	}
    
    	remove_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
    
    }

    Regards,
    Yigit

    #557065

    I added the code. I still see the category.
    Should I update something in it?

    #557066

    Hi!

    Yes, sorry forgot to mention it in the previous post. “knives” in the code is the category that will be hidden. Please replace “knives” with your category name

    Cheers!
    Yigit

    #557073

    I did it, but it is not working.
    I tried name or slug.

    • This reply was modified 8 years, 11 months ago by eyeweb.
    #557559

    Hi,

    Could you please provide us with a temporary admin login so that we can take a closer look? You can post the details in the Private Content section of your reply.

    Regards,
    Rikard

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.