Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.