Displaying only posts in selected category
-
I have a working category page, which displays a featured image and post title inside a box, and goes to the full post when clicked on. The only problem is each seperate category displays all posts (no matter the category). How would I code this to only dislay posts inside the selected category?
My code is below.
<?php /** * The template for displaying Category Archive pages. * * @package Toolbox * @since Toolbox 0.1 */ get_header(); ?> <section id="primary"> <div id="content" class="product_gallery" role="main"> <h1 class="cat_title"><?php single_cat_title(); ?></h1> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <ul> <?php // we add this, to show all posts in our // Glossary sorted alphabetically $args = array( 'posts_per_page' => -1, 'orderby'=> 'title', 'order' => 'ASC', 'category' => 'Piccolos' ); $glossaryposts = get_posts( $args ); foreach( $glossaryposts as $post ) : setup_postdata($post); ?> <div class="product_thumbnail"> <a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail('thumbnail', array('class' => 'thumbnail')); ?> <p class="post_caption"><?php the_title(); ?></p> </a> </div> <?php endforeach; ?> </ul> <?php endwhile; ?> </div><!-- #content --> </section><!-- #primary --> <?php get_sidebar(); ?> <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Displaying only posts in selected category’ is closed to new replies.