WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to request a certain list of posts in the order I want. I'm getting the posts using:

query_posts('category_name'=>'cases', 'posts_per_page'=>5, 'post__in'=>$_SESSION['sorting'], 'paged'=>$paged);

It works in that I get the posts in the array $_SESSION['sorting'] but the problem is that my sorting gets lost even if iI don't suggest a special orderby field.

Can anyone help me?

share|improve this question

migrated from stackoverflow.com Jul 6 '11 at 12:59

This question came from our site for professional and enthusiast programmers.

post__in doesn't affect the ordering at all.

You can achieve the order you want by hooking into the 'posts_orderby' filter and use MySQL's FIND_IN_SET() function.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.