How to Sort by Featured Products on the Shop Page in WooCommerce – 2026

Last updated on November 20th, 2024 at 09:31 am

Sorting by featured products on the shop page is a great way to highlight your top items and encourage customers to explore your best offerings. By sorting featured products at the top of the shop page, you can ensure that these products are seen first, increasing their visibility and driving more sales.

In this guide, we’ll show you how to adjust the WooCommerce shop page to sort by featured products first, without using a plugin.


Step 1: Modify the Shop Page Query to Sort by Featured Products

To sort by featured products on the shop page, we’ll use a custom function to adjust the product query so that featured products appear first in the default sorting order.

Code to Sort Featured Products First on the Shop Page

Add the following code to your theme’s functions.php file or a child theme:

/*
 * Snippet: How to Sort by Featured Products on the Shop Page in WooCommerce – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1695
* Tested with WooCommerce 10.7.0
* "This function modifies the shop page query to sort featured products first"
*/ function wcsuccess_sort_by_featured_products_first( $query ) { if ( ! is_admin() && $query->is_main_query() && is_shop() ) { $meta_query = $query->get( 'meta_query' ); // Add a meta query to check for featured products $meta_query[] = array( 'relation' => 'OR', array( 'key' => '_featured', 'value' => 'yes', 'compare' => '=' ), array( 'key' => '_featured', 'compare' => 'NOT EXISTS' ) ); $query->set( 'meta_query', $meta_query ); // Order featured products first, followed by newest items $query->set( 'orderby', array( 'meta_value' => 'DESC', 'date' => 'DESC' ) ); } } add_action( 'pre_get_posts', 'wcsuccess_sort_by_featured_products_first' );

Explanation:

  • Condition Check: This function only runs on the shop page’s main query on the front end.
  • Meta Query for Featured Products: Adds a meta query that filters products based on the _featured meta key, ensuring that featured products are sorted first.
  • Sorting Logic: Sorts products to display featured items first, followed by non-featured products ordered by the latest date.
See also  How to Create WooCommerce Catalog Mode Without a Plugin - 2026

Step 2: Style Featured Products (Optional)

To make the featured products stand out even more on the shop page, consider applying a custom style. Here’s some optional CSS to highlight featured products.

CSS for Featured Products

Add this CSS to your theme’s style.css file or custom CSS area:

/* Style featured products */
.product.featured {
    border: 2px solid #3498db; /* Blue border */
    padding: 10px;
    border-radius: 5px;
    background-color: #f0f8ff;
}

Explanation:

  • CSS Highlight: Adds a blue border and background to featured products, making them more noticeable on the shop page.
  • Customisable Styling: Adjust colours, padding, and borders to fit your store’s branding.

Example Workflow

  1. Mark Products as Featured: In WooCommerce, set products as “Featured” in the product editor.
  2. Sorting Display: Featured products will now appear first on the shop page, followed by non-featured products sorted by date.
  3. Styling: Optionally, add custom styles to further distinguish featured products.
See also  How to Set Up Advanced Product Filtering in WooCommerce - 2026

Conclusion

Sorting by featured products on the WooCommerce shop page is a simple and effective way to highlight your top items. By following this guide, you can ensure that featured products are seen first, helping to drive more customer engagement with your best products.

For more customisation options, explore our WooCommerce Visual Hooks Guide or our wp-config generator for advanced configurations.

0 0 votes
Article Rating

Stay In Touch

Was this post helpful? Why not show your support and buy me a coffee?

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top
0
Would love your thoughts, please comment.x
()
x
×