List Recent Posts from Specific Category – WordPress

You can list post from specific category by query_posts() function. it will take one or two parameters, one is category name and 2nd is no of post to show. like following code is showing exactly how it work.

and full code to show posts

and for normal code is here:

query_posts() is a function which can also be used for custom post type. if you have some custom post type and want to show posts from , you can use this function. its take many parameters on the basis of which you can collect your required posts from db. in that case you will use to pass a list of array to this function and it will grab you required data.

or you can pass directly to function.

in above code it will collect posts from category=3, year=2004 and tag=’phone’. so overall its amazing function to grab custom data from WordPress and can reduce your hurdle many times.