I want to display the all the posts that are inside a certain subcategory in a specific order that I decide (this is because the category contains a list of tutorials and I want to decide how to list them).

How can I do that?

Is there any plugin that I can use? I just want to be able to set the order when displaying that category.


  • What order are you talking about? Different from the originally available or would you be fine with those?
    – tfrommen
    Apr 18, 2013 at 13:44

2 Answers 2


You can use the get_posts() function and create a custom template file for that! This way you can take advantage of all the arguments that function makes use of. For example, to show all posts from a category that has id=47 you would do the following:

global $post;
$args = array( 'numberposts' => 999, 'category' => 47, 'orderby' => 'post_date', 'order' => 'DESC',);
$myposts = get_posts( $args );
foreach( $myposts as $post ) :  setup_postdata($post); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>

This will echo the titles of 999 posts (each title linking to the post itself) and it will format them as a list with the <ul>, <li> that we used. Of course you'll have to customize that to suit your use-case but this is a working principal.

I hope that helps!

Cheers, Ari.

  • Thanks for your reply. I've probably not explained fully my point. I need to order the blog posts with a specific order that I decide (and that I can change). For example, I want to display the posts in the order 3,5,8,4. How can I do that?
    – nagar
    Apr 18, 2013 at 14:17
  • You could add a custom field to those post. Let's say that this custom fiels is called "order_nr". In that case, you'd be able to format the arguments of the above query like this: $args = array( 'numberposts' => 999, 'category' => 47, 'meta_key' => 'order_nr', 'orderby' => 'meta_value', 'order' => 'ASC',); Apr 18, 2013 at 14:31
  • Are you aware of any plugin that allows to do that visually? Anyway, I'll check your suggestion. Thanks.
    – nagar
    Apr 18, 2013 at 18:14

post__in will preserve the order of the values you give it.

'post_in' - Preserve post ID order given in the post_in array (available with Version 3.5).


Assuming that "3,5,8,4" are post IDs, something like the following should work:

$query = new WP_Query( 
  array ( 
    'post__in' => array(3,5,8,4)

Of course, you will need to add other parameters that you might want.

Note: It is cat not category, but it doesn't matter since post__in will take care of everything anyway. That is, if you are picking the posts to display by ID, as it sounds like you want to do, you don't really need any other parameters.

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.