0

I have set up a custom loop to display featured products at the top of their relevant category pages.

but now I would like to go about removing featured products from the regular loop below, which is using the standard woocommerce code to display products,

Any help would be greatly appreciated

http://onthesquareauctions.com/index.php/product-category/emporium/furniture/chairs-emporium/ enter image description here

  • Nothing we can do if you don't show the code you are using. – cjbj Sep 27 '16 at 12:46
  • Please write some codes, and are you using WooCommerce? – Ahmed Fouad Sep 27 '16 at 12:59
  • sorry, meant to say I'm just using the default woocommerce code for the second loop, i.e. the one i want to remove the featured products from. – AlastairNixon Sep 27 '16 at 13:27
1

Use the pre_get_posts filter to remove your sticked product from the product loop.

add_action( 'pre_get_posts', 'exclude_stycky_product' );

function exclude_sticky_product(){
    // target only the main query
    if ( ! is_admin() && $query->is_main_query()  ) {
         $query->set('ignore_sticky_posts');
         $query->set('meta_value', '1');
    }
}

Hope it helps you !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.