Last active
July 25, 2020 09:22
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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