-
AuthorPosts
-
December 22, 2015 at 4:55 pm #556631
Hi,
I am using products slider.
Is it possible to display only featured products?December 22, 2015 at 9:03 pm #556721Shalom!
Can you please add a new product category and choose to display only those products on your product slider?
Cheers!
YigitDecember 23, 2015 at 8:20 am #556916Hi,
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.December 23, 2015 at 4:32 pm #557040Hi!
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!
YigitDecember 23, 2015 at 4:47 pm #557056Here it is.
Can you please post the explanation how did you do it?December 23, 2015 at 4:52 pm #557059Hey!
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,
YigitDecember 23, 2015 at 4:58 pm #557065I added the code. I still see the category.
Should I update something in it?December 23, 2015 at 4:59 pm #557066Hi!
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!
YigitDecember 23, 2015 at 5:08 pm #557073I did it, but it is not working.
I tried name or slug.-
This reply was modified 9 years, 11 months ago by
eyeweb.
December 27, 2015 at 6:58 am #557559 -
This reply was modified 9 years, 11 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.
