Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress

Robert James
Robert James
20,491 Points

WooCommerce and setting up different product pages

I am currently going through the E commerce with WordPress and Woo Commerce tutorials. I currently have a project where i have built a website for an artist. On the site there is a nav option for artwork which has a dropdown menu for 6 different areas of his artwork, eg. Landscapes, abstract, portraits etc...

I built this as a static HTML site to start and am currently developing that into a WordPress theme with the final object being able to sell the artwork through WooCommerce.

Basically i want like 6 pages with the template page-portfolio.php which will each be a page of thumbnails consisting of the artwork from each section. When one image is clicked it takes you to single-portfolio.php, but i also want this to be the single product page with the 'buy now' button.

Or would everything need to go through woocommerce and is it possible to have 6 "shop" pages?

Hope i have been clear in what im getting at?

Thanks in advance, Rob

1 Answer

Sue Dough
Sue Dough
35,800 Points

Hi Robert,

Woo Commerce has its own loops for displaying products so you will want to use that. You don't want to have to edit your code every time you add a new product. You will then want to create Woo Commerce categories for those specific 6 pages. Then you can easily assign products to categories.

Here is a sample woo commerce loop to show 10 products

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

Take a look at some free Woo commerce themes to get a better understanding on the structure of them. Reverse engineer what you need to out of them.