WordPress Include woocommerce-products in a one-page layout

So I’m making a one-page-site for a client, which includes a webshop. Now each WP-pages makes up a slide. The slides uses different theme-templates and in one of the slides called “Shop” I want to display all WooCommerce-products (it uses the template slide-shop.php .
Right now the <ul class="products"> is echoed, however the content of it is empty. If you go to the page url (site.com/shop) all products show fine.

one-page.php:

Read More
 <?php 
    $pages = get_pages(array('sort_column' => 'menu_order'));
    $i = 0;
    foreach ($pages as $page_data) {
        $page_ID = $page_data->ID;
        //$slug = $page_data->post_name;
        $content = apply_filters('the_content', $page_data->post_content);
        $title = $page_data->post_title;
        $template = get_page_template_slug( $page_ID );
        $i++; 
?>  

<section id="slide-<?php echo $i; ?>" class="slide cf">
    <div class="slide-wrap cf">         
        <div class="slide-con item cf" >            
            <?php include($template); ?>
        </div>
    </div>
</section>  
<?php 
    } /*end foreach*/
?>

slide-shop.php:

/*
 Template Name: Slide w. shop
 */
?> 
    <div class="slide-header cf">
        <h2><?php echo $title ?></h2>
    </div>
    <div class="slide-body cf">
        <div class="col d-1of2 cf">
            <?php echo $content ?>

        </div>

        <div class="col d-1of2 cf">
                <?php woocommerce_content(); ?>
        </div>
    </div>

Related posts

1 comment

  1. Documentation for woocommerce_content states:

    This function is only used in the optional ‘woocommerce.php’ template. which people can add to their themes to add basic woocommerce support. without hooks or modifying core templates.

    So in your case the solution would be to replace

    <?php woocommerce_content(); ?>

    with

    <?php echo do_shortcode("[products]"); ?>

    That should get the products to appear in your slide.

Comments are closed.