Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameshwartlopez/f2096c82f0ef4293640713ed9a5ad86b to your computer and use it in GitHub Desktop.
Save jameshwartlopez/f2096c82f0ef4293640713ed9a5ad86b to your computer and use it in GitHub Desktop.
Show featured products first. Above the normal product list. See https://jameshwartlopez.com/plugin/show-featured-products-in-product-category-pages/
<?php
/*
Show featured products first. Above the normal product list
*/
add_action('woocommerce_before_main_content', function() {
if(is_product_category()) {
$current_term = get_queried_object();
echo '<h2> Featured '.esc_html($current_term->name).'</h2>';
echo do_shortcode('[featured_products_by_category cat="'.$current_term->slug.'" limit=3]');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment