How to Get and Display Featured Products with Thumbnail in WP e-Commerce Plugin

WP e-Commerce is an e-Commerce plugin provided by Instinct Entertainment, A plugin that provides a WordPress Shopping Cart or all Downloadable products like mp3, pdf and etc, now you can turn your WordPress site into an e-Commerce or Shopping site, WP e-Commerce provided lots of built in widgets that you can drag to show it in your site sidebar like Latest Products Widget, Shopping Cart Widget, Product Specials Widget, Donations Widget, WP-e-Commerce Live Search where you can search products like in Apple site search and it’s amazing isn’t it? And many more, and one thing they forgot is the Featured Products and this time I will share you how to add Featured Products in your e-Commerce site.

In this tutorial we’re going to use shortcode.

Step 1:

Open functions.php in your theme directory or if you don’t have one please create functions.php file.

Step 2:

Copy and paste the PHP snippet below and paste it into yourfunctions.php, this script read all featured products that you’re being stared/featured.

Want to display product from a category?

Thanks to Nicole Brooke for lettings us know for this solution.


Okay let’s define the functions we’re using above.

  • wpsc_the_product_title(): This will simply display the product title.
  • wpsc_the_product_thumbnail(): This function display the product thumbnail with size parameters.

How to use the shortcode?

To use the shortcode into your post, page or even in widget area just pastes this one line of code.

To add parameters, e.g. the numbers of post to display, update the code above to this.

See above for more shortcode parameters.


If the shortcode didn’t work, visit this page for troubleshooting tips Display Posts in the Sidebar on Specific Category Only – WordPress.

Don’t want to get your hands dirty?

Not a problem, here I provided Featured Products plugin from other developer WP e-Commerce Featured Product.

That’s it, its easy right?

by Ryan Sutana

  • What’s up to all, how is all, I think every one is getting more from this web page, and your views are pleasant in support of new users.

  • shnalla

    Hi, many thanks for your code, was very helpful 🙂

    • no problem @shnalla I’m glad my article is useful.

  • franz

    hi there

    i wanted to make this in one page

    Salads(Category Name)
    – Fruit (product name)
    – Buko (product name)
    – Macaroni (product name)

    – pan de sal
    – monay
    – ensaymada

    how could i do this? i think i can use shortcodes to display this but i know there is other way to do this.

    • Hi @franz, yeah there are other way to do it, you can you use query_posts( $args ); functions to get all post, just add post_type parameter as ‘wpsc-product’ 😉

      Hope that helps

  • franz

    hi there again

    how about i want to display the latest products using shortcode, which part of your code should i modify so it will display the latest products added

    • No need to modify my code ;), my code is pretty much it, all you need to do is defined the attribute or parameters, see the orderby, order and posts_per_page use that parameters 😉

      hope that helps.

  • marj

    hi, looks like this one is very useful
    i have used it to display all products

    and now i wanted to display products by category? what to modify in your code or how to do it?

    • To display products by category you need to add
      ‘category_name’ => ‘my-category-slug’ in the $args array above and if you’d like to display one or more category you can do ‘category__and’ => array(1,3)

      hope that helps.

  • happynuclear

    Sweet little shortcode there mate, you helped me out heaps! Thanks again =)

    • I’m glad it help, happynuclear

  • Jewel

    Thanks bro…

    • no problem @4b12b6b19696f617976c1decbbebb750:disqus

  • David

    I want add “Buy” button, so how i edit code ? Thanks

    • To display Buy button add this shortcode

      [buy_now_button product_id=’188′] – Displays a PayPal buy now button for the prdouct with the id of 188

      [add_to_cart=379] – Display an add to cart button for the product with the ID of 379

      use get_the_ID() to get recent post ID, you can add the code after or below Product Title as long as it is under the while loop.

  • whatiadore

    this is great! is there a way to do the same thing for ‘latest products’ ?

    • Hi @whatiadore,

      No different for displaying latest products, what you need to change is the “order” and “posts_per_page” for the number of posts to display.

  • How do I add this to a template? what would the template code be?

    • Hi Nicole Brooke

      To display latest added you need to remove ‘post__in’ => $sticky, parameter as that only read featured products and yes you’re right to display product in category you only need to add ‘category_name’ => ‘my-category-slug’, also to make sure you get latest added product use ORDER and ORDER BY.

      Hope that helps.

      • HI Ryan, thanks for getting back to me, if I do as per your instruction I am left with the following code but as this is on my home page, it only returns the date in the home page loop, not the products in the category?;

        global $post;
        $sticky = get_option( ‘sticky_products’ );

        $args = array(
        ‘post_type’ => ‘wpsc-product’,
        ‘posts_per_page’ => 6,
        ‘orderby’ => ‘date’,
        ‘category_name’ => ‘specials’,
        ‘order’ => ‘DESC’,
        ‘include’ => ”,
        ‘exclude’ => ”,
        ‘post_status’ => ‘publish’,
        query_posts( $args );

        • okay I think I got it, add this function “wp_reset_query();” after your loop or refer in Step 2 I’ve updated the code.

          or if still didn’t work use WP_Query() instead, don’t worry query_posts() use that class so same parameters.

          NOTE: use that function after in every query_posts() loop in order the second loop to works.

          • thanks for tolerating me! when I add wp_reset_query(); i get nothing – if i remove ‘category_name’ => ‘specials’, i get all products. If I add WP_Query() instead of wp_reset_query(); i get the same products as the sticky query (featured products) in my first tab.. just cant seem to get it to work.

          • you sure your “specials category” is “specials” slug? also the WP_Query() syntax is like so

            $special_qry = WP_Query( $args );

            if ( $special_qry->have_posts() ) {
            while( $special_qry->have_posts() ) :

            if still wrong, please add your code here instead :), in that we can review your code.

          • Sorry now im confussed. Yes, specialis is def the slug – i now have the following which is causing errors

            global $post;
            $sticky = get_option( ‘sticky_products’ );

            $args = array(
            ‘post_type’ => ‘wpsc-product’,
            ‘posts_per_page’ => -1,
            ‘orderby’ => ‘date’,
            ‘order’ => ‘DESC’,
            ‘category_name’ => ‘specials’,
            ‘include’ => ”,
            ‘exclude’ => ”,
            ‘post_status’ => ‘publish’,

            $special_qry = WP_Query( $args );

            if ( $special_qry->have_posts() ) {

            while( $special_qry->have_posts() ) : $special_qry->the_post();


          • FYI, i found a solution at thanks for your help.

          • Hi @facebook-759587064:disqus thanks for letting me know, I didn’t know that they have their own parameter hmmm

  • Dima Um

    Just want to let you know, the code does not work on latest wp-ecommerse installation.

    • Yeah it works ;), I’m using the latest version too.

  • Pingback: Display Best Selling Products in WP e-Commerce | Sutana Ryan's Blog and Portfolio Site()

  • Kennedy

    Does anyone have idea why wpsc_the_product_thumbnail() from WP e-Commerce Related Product Version 1.3.2 By Onnay Okheng does not display the related product thumbnail but other attributes like product title and price works just fine. This problem started when I upgraded to latest wordpress 3.7 but i did not update the WP e-commerce as I want it to be under this version Then I tried to update WP e-commerce to latest version but still the the product thumbnails are not shown.

  • Sushovan kamila

    wp e-commerce Plugin shortcode of Display latest 3 products

    • Hi @sushovankamila:disqus please check your email

      • The code does work and please use this for our conversation and don’t add new comment just saying it didn’t work, also saying it didn’t work you have to elaborate more, it give you error, warning or etc.?

        To display latest product is simple, since WP e-commerce is using custom post-type so we can use WP_Query() to fetch WP e-commerce posts and order by date desc.

  • Sushovan kamila

    the code does not work Please,Say display Latest products