I'm trying to list all posts from a certain category, in a list, on the category page that already lists the posts out in blog form. I'm trying to do it in the header area so that you can get an overall look at the posts on the page. I found this:
<ul> <?php global $post; $category = get_the_category($post->ID); $category = $category->cat_ID; $myposts = get_posts(array('numberposts' => 5, 'category__in' => array($category), 'post__not_in' => array($post->ID),'post_status'=>'publish')); foreach($myposts as $post) : setup_postdata($post); ?> <li> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a> </li> <?php endforeach; ?> <?php wp_reset_query(); ?> </ul>
But it always seems to cut one of the posts out of the list. Is there an easier way to do this, without a plugin?