好的,那么您想自己定义帖子顺序。WP\\U查询允许您这样做-您必须使用orderby
=> post__in
实现它。你就是这么做的。
那它为什么不起作用呢?因为输入错误;)
按订购帖子post__in
保留“post\\uu in”数组中给定的post ID顺序。但你不能通过post__in
查询中的参数(您通过post__in
- 末端的额外空间)。
$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 );
所以这应该很好:
$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 );