calling product category by loop

On the front page of the site I would like to get all the products in one category and display the product name, price and order quantity box (so that a user can order as many bottles of wine as they like) but I am unsure how to call all get all products from a category. The website is a one page site and the is also running the wp-loop on the same page so there would need to be no conflicts there

Is there documentation somewhere where I can find how to call products from a category? call the product price? call a quantity box?

  • Arun Basil Lal
    • New Recruit

    Hey there,

    Welcome to the Community!

    You can use the shortcode [mp_list_products] for this. Details of this is provided in the shortcode tab on the MarketPress settings:

    [mp_list_products category="categoryname"]

    Use it on a page and then use the page as the homepage. You can do it via Settings > Reading in WordPress .

    I hope this makes sense. Let me know. Good luck!

  • nathanshanahan
    • New Recruit


    Im not sure shortcodes are going to help me here. I tried the implementation you suggested and while I was able to call the products successfully by category I’m having a conflict with my the blog loop which also runs on the same page.

    I have the following code working without interfering with the blog:


    // The Query

    $the_query = new WP_Query( $args );

    // The Loop

    $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 10 );

    $loop = new WP_Query( $args );

    while ( $loop->have_posts() ) : $loop->the_post(); ?>

    <article class=”purchase_wine”>

    ” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></h3>


    <?php endwhile; ?>

    <?php wp_reset_postdata(); ?>`

    but what I would like to know is how to modify this so that it:

    1.) calls all the products by the category slug

    2.) displays the product with the option to enter a quantity that you wish to buy (i.e – not the add to cart button but a enter quantity button.

    the second being my biggest hurdle to overcome

    Any assistance would be greatly appreciated.

  • nathanshanahan
    • New Recruit

    I should add that when I attempt to call any reference like wpsc_product_normal_price() I’m getting a fatal error:

    Fatal error: Call to undefined function wpsc_product_normal_price() in /nfs/c06/h04/mnt/92123/domains/ on line 14

  • Aaron
    • CTO

    As you can’t use a shortcode, you’ll want to use the related template function in your index.php or home.php template file.

    * function mp_list_products
    * Displays a list of products according to preference. Optional values default to the values in Presentation Settings -> Product List
    * @param bool $echo Optional, whether to echo or return
    * @param bool $paginate Optional, whether to paginate
    * @param int $page Optional, The page number to display in the product list if $paginate is set to true.
    * @param int $per_page Optional, How many products to display in the product list if $paginate is set to true.
    * @param string $order_by Optional, What field to order products by. Can be: title, date, ID, author, price, sales, rand
    * @param string $order Optional, Direction to order products by. Can be: DESC, ASC
    * @param string $category Optional, limit to a product category
    * @param string $tag Optional, limit to a product tag
    mp_list_products( $echo = true, $paginate = '', $page = '', $per_page = '', $order_by = '', $order = '', $category = '', $tag = '' )

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.