what code will make only one category of post show on template page
-
Hi all,
I’m building a couple of template pages.
I’ve got a site with a bunch of pages. I want to put posts from one category on one page and posts from another category on a second page.
I tried this code:
<?php if (have_posts()) : ?> <?php $cat = get_the_category(); $cat = $cat[6]; ?> <?php query_posts(array( 'cat'=> $cat->cat_ID, 'showposts'=>'5', ) ); ?> <?php while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"> <?php the_title(); ?></a></h2> <span class="post-date" title="Date"><?php the_time('F j, Y') ?></span> <span class="post-cath" title="Category"><?php the_category(', ') ?></span> <span class="post-comm"> <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></span> <span class="post-edit"><?php edit_post_link('Edit','',''); ?></span> <span class="entry"><?php the_content('Read the rest...'); ?></span> </div> <?php comments_template(); ?> <?php endwhile; ?>
But that shows all posts.
can someone suggest a better way to select only one category?
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘what code will make only one category of post show on template page’ is closed to new replies.