Cailean
Member
Posted 3 years ago #
I'm trying to pull posts that belong to two categories. So if I have four categories (A, B, C, D) I want to pull only posts that are in A and B. Not to be confused with pulling all posts from A and B.
Any help? query_posts() doesn't seem to be able to do it.
Does this example from the Codex article, query_posts(), work for you?
query_posts(array('category__and'=>array(1,3),'showposts'=>2,'orderby'=>title,'order'=>DESC));
webmatter
Member
Posted 3 years ago #
Many thanks, just what I was looking for!
I was trying to do the same. Doesn't seem to work though. It works if I enter one category ID only. As soon as I add a second category all I get is empty space.
I copied the exact same code, justed altered category id's.
What am I doing wrong?