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:
<?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>
Documentation for
woocommerce_content
states: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.