Adding Woocommerce shortcode in PHP to home page of other Theme (7 posts)

  1. finleydesign
    Posted 3 years ago #

    Ok any whizz kids want to help me, I have a non Wootheme I am using, which I have recently added woocommerce too, with some major CSS work I have managed to get it to work very well regarding products.

    However I would like to use a hook or shortcode in the PHP of the themes home page to show say 10 of all products

    I have tried many methods of php echo do_shortcode etc but it simply breaks the site, must be missing something

    I kind of understand the shortcode does reside in the main wordpress set up so maybe this is the problem

    But any clever chaps want to give me some pointers it would be appreciated


  2. Roy Ho
    Posted 3 years ago #

    WooCommerce shortcode is not dependent on a wootheme's theme. So it will work on any theme as long as WooCommerce is installed.

    So I am not sure what exact issues you're seeing. So perhaps elaborate on what you mean by "breaks the site".

  3. finleydesign
    Posted 3 years ago #

    Ok so I am going to home.php and under the last section of post I want to list certain product categories I am using the following

    <?php echo do_shortcode("[product_category category="gold-silver-courses" per_page="12" columns="2" orderby="price" order="desc"]"); ?>

  4. Roy Ho
    Posted 3 years ago #

    Again, you're not stating how it breaks...Are you seeing errors messages? Are you seeing weird layouts? What?

  5. finleydesign
    Posted 3 years ago #

    Oops sorry - no the page just goes white and nothing, the site stops working altogether

  6. Roy Ho
    Posted 3 years ago #

    Try this instead:

    <?php echo do_shortcode('[product_category category="gold-silver-courses" per_page="12" columns="2" orderby="price" order="desc"]'); ?>

    And post your URL, that always helps.

  7. finleydesign
    Posted 3 years ago #

    Your a star!!! that worked perfectly should have spotted the " "

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.