Querying Posts Using Categories
-
Hi,
I want to return posts dependant on the categories they are in, is this possible?
For example:
post1 is associated with 2 categories, category_name1 and category_name2
post2 is associated with 2 categories, category_name1 and category_name3
post3 is associated with 2 categories, category_name2 and category_name3
I only want to return post1 and not post2 or post3 querying only on category_name.
I’ve tried this but it’s not working as I had expected.
//The Query $cat1 = get_cat_ID($category_name1); $cat2 = get_cat_ID($category_name2); $args = array('cat' => $cat1 . ',' .$cat2); query_posts($args); //The Loop if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; endif; //Reset Query wp_reset_query();
Thanks.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Querying Posts Using Categories’ is closed to new replies.