0

According to:http://codex.wordpress.org/Function_Reference/query_posts

To show all posts in a category:

query_posts( array ( 'category_name' => 'The Category Name', 'posts_per_page' => -1 ) );

Works great, but if I want to show the posts

ORDER BY ID DESC

Anyone have any idea how to do that?

2 Answers 2

3

You need to use this to parameters orderby and order

<?php query_posts( array( 'category_name' => 'my_category_slug', 'orderby' => 'ID', 'order' => 'DESC', 'posts_per_page' => -1 ) ); ?>
0
0

the param order can list via DESC and the param orderby sort by ID for your example:

query_posts( 
   array ( 'category_name' => 'The Category Name', 
           'posts_per_page' => -1,
           'orderby' => 'ID',
           'order' => 'DESC'
   )
);

oder is only usable with ASC or DESC and orderby can use all fiels of the table posts.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.