最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Woocommerce new shop page

programmeradmin3浏览0评论

I would like to have a page like page.php to display the content of the shop page. How can i do it?

I copied everything from woocommerce/archive-product.php in to page.php but nothing is beeing displayed.

I would like to have a page like page.php to display the content of the shop page. How can i do it?

I copied everything from woocommerce/archive-product.php in to page.php but nothing is beeing displayed.

Share Improve this question asked Apr 19, 2019 at 7:50 Alessandro CraciunAlessandro Craciun 1
Add a comment  | 

1 Answer 1

Reset to default 0

Personally i would create a custom template and not use page.php and add a simply product loop

Quick break down

create new template called customshop.php

<?php /* Template Name: Custom Shop */ ?> 

add your shop loop

<ul class="products">
    <?php
        $args = array(
            'post_type' => 'product',
            'posts_per_page' => 12
            );
        $loop = new WP_Query( $args );
        if ( $loop->have_posts() ) {
            while ( $loop->have_posts() ) : $loop->the_post();
                wc_get_template_part( 'content', 'product' );
            endwhile;
        } else {
            echo __( 'No products found' );
        }
        wp_reset_postdata();
    ?>
</ul><!--/.products-->

create your new page in pages and change your template to your new page in the drop down

logic behind adding the loop as a custom template is purely for neatness and you may want a variety of custom templates and adding customshop.php means you can add lots more and you are keeping your structure neat

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论