I would like some help with the following issue with woocommerce.

I am using wordpress 3.5.2, woocommerce 2.0.13 and sommerce theme.

I have a product category page, in which I display 5 subcategories. Under the 5 subcategory images, I would like to have some featured products or random products of these categories. Do you know how I could do that?

  • woocommerce has some widgets that can do the trick. Just check it.
    – JMau
    Jul 26, 2013 at 18:53

2 Answers 2


I just double checked and WooCommerce runs the product category description through the_content filters, which means that it should run shortcodes.

WooCommerce has plenty of shortcodes, see their documentation

Including featured products:

[featured_products per_page="12" columns="4"]

The downside to that is that the featured products might not all be from that specific category. You didn't mention if that was an issue or not.

If so, then you can duplicate the code from the [featured_products] (which is really just running a secondary loop with WP_Query), tweak it a bit and add the output to the woocommerce_before_shop_loop hook.

function wpa_107952_featured (){

    if( !is_product_category() )

    $args = array(
        'post_type' => 'product',
        'product_cat' => get_query_var('product_cat'),
        'post_status' => 'publish',
        'ignore_sticky_posts'   => 1,
        'posts_per_page' => 8,
        'meta_query' => array(
                'key' => '_visibility',
                'value' => array('catalog', 'visible'),
                'compare' => 'IN'
                'key' => '_featured',
                'value' => 'yes'


    $products = new WP_Query( $args );

    $woocommerce_loop['columns'] = 4;

    if ( $products->have_posts() ) : ?>

        <?php woocommerce_product_loop_start(); ?>

            <?php while ( $products->have_posts() ) : $products->the_post(); ?>

                <?php woocommerce_get_template_part( 'content', 'product' ); ?>

            <?php endwhile; // end of the loop. ?>

        <?php woocommerce_product_loop_end(); ?>

    <?php endif;


    echo '<div class="woocommerce">' . ob_get_clean() . '</div>';

add_action( 'woocommerce_before_shop_loop', 'wpa_107952_featured' );

This is a bit late but for people who are looking for answers you can download, install and activate https://wordpress.org/plugins/featured-products-by-category/ it uses the latest and standard woocommerce function wc_get_products.

Once activated put the following code in your functions.php


   Show featured products first. Before the normal product list
add_action('woocommerce_before_shop_loop', function() {

    if(is_product_category()) {
        $current_term = get_queried_object();
        echo do_shortcode('[featured_products_by_category cat="'.$current_term->slug.'" limit=3]');

See the full post here -> https://jameshwartlopez.com/plugin/show-featured-products-in-product-category-pages/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.