I used post__in key to get posts from the specific post ids and order order posts by the other array specific post ids.

I have following:

$orderby_post_ids = array(300,800,500); 
//$order=Ascending/ Descending;

If it Ascending order, expected output should be like this,


If it Descending order, expecting output should be like this,


How do I achieve above result using WP_Query? I used below arguments, but the result is not as expected.

$args = array(
        'post_type' => 'mycourses',
        'posts_per_page' => 4,
       'orderby' => 'post__in', 
       'order' => 'ASC',
       'post__in' => $post_ids,
  • What are the results you are receiving? – Welcher Oct 4 '18 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.