WordPress.org

Forums

WooCommerce - excelling eCommerce
[Custom template]Including shop page in index.php (2 posts)

  1. kaz_
    Member
    Posted 8 months ago #

    Hi !

    I'm building a "one page" design theme for a client, with an e-commerce section using woocommerce.

    So I need my shop page (showing all products) to be included in index.php.

    So I read the documentation and with the help of this page i decided to use this :

    <section id="shop" class="viewport">
          <?php woocommerce_content(); ?>
     </section>

    But everything I get is only a empty ul :

    <section class="viewport" id="shop">
         <h1 class="page-title">Boutique</h1>
             <ul class="products"></ul>
    </section>

    I have 1 product that is visible and available, and it's not showing :( .
    I tried to use the Loop to display directly the shop page by its ID, I had the same behavior.

    But when I'm making my query to the shop page like this <?php query_posts('page_id=4'); ?> and then use the woocommerce_content(); function I get the title, and the message "Here's the only result:" (not sure if it's like this in english version), but my ul.products is still empty...

    What am I doing wrong ?

    Thanks for your help :) !

    Kaz

    https://wordpress.org/plugins/woocommerce/

  2. surge74
    Member
    Posted 8 months ago #

    Why not use the product short code?

    [products ids="1, 2, 3, 4, 5"]

    and echo it in the index page where you want like so:

    <?php echo do_shortcode('[products ids="1, 2, 3, 4, 5"]'); ?>

    If you want to display the whole single product page you can use this:

    <?php echo do_shortcode('[product_page id="99"]'); ?>

    Just change the id to yours

Reply

You must log in to post.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic