I have used the CptUI plugin to create a 'Products' CPT. The admin side of things seems to work fine but I can't quite get the front end to display how I'd like.
For example I create a product, say "Guitars" and another called "Drums". Their permalinks in admin are dispay as
http://mysite.com/products/drums respectively which looks great. However, when I navigate to one of the URLS, I see a page that lists all the current products. This makes sense considering my
single-products.php contains the following:
<?php /*Template Name: Products Template */ get_header(); ?> <div id="primary"> <div id="content" role="main"> <?php $mypost = array( 'post_type' => 'products', ); $loop = new WP_Query( $mypost ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post();?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <header class="entry-header"> <div style="float: right; margin: 10px"> <?php the_post_thumbnail( array( 100, 100 ) ); ?> </div> <strong>Name: </strong><?php the_title(); ?><br /> </header> <div class="entry-content"><?php the_content(); ?></div> </article> <?php endwhile; ?> </div> </div> <?php wp_reset_query(); ?> <?php get_footer(); ?>
What I'd ideally like is for
http://mysite.com/products/guitars to display only the single CPT with the guitars content, (the same for the drums) and then
http://mysite.com/products to display all the products (As it currently does for
http://mysite.com/products/guitars). Is this possible and if so, how?