WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to build a little module onto the product-archive template for WooCommerce that will accomplish one goal.

I have included custom meta fields on the category editor page so that I can paste in specific product SKUs on that page to have as Featured Products. However, I need to figure out a way to have WooCommerce query the current category of products and list the product that has the same SKU that I have listed in the category meta.

in other words...

Product Category -> Custom Meta Field (Product Sku) -> On Product Category Page, Display Product With Matching SKU from current category.

Is something like this even possible? I have been wracking my brain for hours trying to get this to work. Honestly, it doesn't seem like that crazy of an idea, but there is just nothing available that I can with a bit of guidance in the correct direction.

share|improve this question

WooCommerce uses Custom Post Types for its products and as such uses standard WP_Query to return results on those pages. You can probably use the pre_get_posts() to modify the query on certain pages or archives.

WordPress Codex Page for pre_get_posts()

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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