Does the ‘cat’ argument in query_posts fetch posts from subcategories as well as the given ID?

Hello friends I am new to wordpress.

I have used query like this query_posts(‘cat=1,2,3’)

now If category 1 is parent of 2 and 3.

then query_posts(‘cat=1’) and query_posts(‘cat=1,2,3’) will get same posts or not?
or how can I manage If I want to include posts form subcategories.

3 Answers
3

In short: Yes.

Your question is about the query_posts WordPress PHP function. The link I’ve placed is the official wordpress codex documentation for that function.

For your example it states:

Display posts from only one category ID (and any children of that category):

query_posts('cat=4');

I hope this information is helpful. You find more infos in codex, the function is pretty powerful.

Leave a Comment