So I'm trying to query some posts from 1 category only and it does seem to be working. I tried get_post() also but no luck and after awhile I just caved and used query_posts (which is apparently bad practice). Here's my code:
<div id="primary"> <div id="content" role="main"> <?php query_posts('slug=cat1'); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="post"> <h1> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php the_title(); ?> </a> </h1> <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small> <br /> <br /> <div class="entry"> <?php the_content(); ?> </div> </div> <hr /> <?php endwhile; else: ?> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> <?php endif; ?> </div><!-- #content --> </div><!-- #primary -->
endif; is from above I have a test against the page slug. But from my understanding the query_posts should populate $post with all the posts from that category but I'm still getting posts from uncatagorized and another category so it's not filtering at all... Suggestions?
Edit1 I tried using
cat=2 but the only one that actually filters is the
cat=1 which filters to uncategorized. All the others show all posts. Not sure why...
query_posts( array ( 'category_name' => 'Category1', 'posts_per_page' => -1 ) ); returned with the "else" statement saying there was no posts and nothing fit my criteria. I pulled that straight from the codex?