• SpecialMonkey

    (@chris81083)


    We offer 2 types of products, ‘products’ and ‘showroom’ we want to display our products first then the showroom items when someone searches. Our search function is using Woocommerce search.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    WP_Query class is typically used to query for products and any other post types. Oddly enough, WP_Query cannot accommodate ordering query results by taxonomy terms like categories. You could instead make two queries, one for products, then again for showroom items. How you’d accomplish this involves customizing the search results template used by WooCommerce. WooCommerce has their own dedicated support channels where support staff there are in the best position to advise on customizing WC templates.

    A different approach would be to compose your own search SQL query that is capable of ordering by category. You can use the “posts_request” filter to replace the SQL that WP_Query came up with with your own SQL.

Viewing 1 replies (of 1 total)
  • The topic ‘Display by Categories in search results’ is closed to new replies.