OK, so you want to define posts order by yourself. WP_Query allows you to do that – you’ll have to use orderby
=> post__in
to achieve it. And that’s what you do.
So why isn’t it working? Because of a typo 😉
Ordering posts by post__in
preserves post ID order given in the ‘post__in’ array. But you don’t pass post__in
param in your query (you pass post__in
– additional space at the end).
$ids = array('16085','16088','16083','16091');
$options = array(
'post_type' => $post_type,
'posts_per_page' => $posts_per_page,
'paged' => $paged,
'meta_query' => $meta_query,
'tax_query' => $tax_query,
'post__in ' => $ids, // <-- here is the additional space
'orderby' => 'post__in',
);
$get_properties = new WP_Query( $options );
So this should work just fine:
$ids = array('16085','16088','16083','16091');
$options = array(
'post_type' => $post_type,
'posts_per_page' => $posts_per_page,
'paged' => $paged,
'meta_query' => $meta_query,
'tax_query' => $tax_query,
'post__in' => $ids, // <-- there is no space anymore in here
'orderby' => 'post__in',
);
$get_properties = new WP_Query( $options );