query_posts with specific category_name but all posts are retrieved
-
Hello all,
I am using query_posts() to retrieve some posts in a specific category. My code is like this:
$posts = query_posts("name=$name&category_name=$category_slug");
But the problem is it seems like the
category_name
parameter is ignored, just thename
is looked atEg, I have a post with the name of “My Post” and its category is “cat1”; I also have another category which is “cat2”. When I tried the code below, I guessed the post should NOT be retrieved, but it was still included in the result:
$name = 'My Post'; $category_slug = 'cat2'; // yes, 'cat2' for not including 'My Post' $posts = query_posts("name=$name&category_name=$category_slug");
Please give me any clue. Thank you all so much!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘query_posts with specific category_name but all posts are retrieved’ is closed to new replies.