Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用WP\u查询按post\u id键而不是按值排序_Php_Mysql_Wordpress - Fatal编程技术网

Php 如何使用WP\u查询按post\u id键而不是按值排序

Php 如何使用WP\u查询按post\u id键而不是按值排序,php,mysql,wordpress,Php,Mysql,Wordpress,我将post_id传递给WP_Query(),如下所示 $result_post_ids = $wpdb->get_results("SELECT DISTINCT auction_id FROM " . $wpdb->prefix . "simple_auction_log WHERE userid = $user_id order by date DESC"

我将post_id传递给WP_Query(),如下所示

$result_post_ids = $wpdb->get_results("SELECT  DISTINCT auction_id 
                   FROM " . $wpdb->prefix . "simple_auction_log 
                   WHERE userid = $user_id 
                   order by date DESC" , ARRAY_N);

  $args = array (
            'post__in' => $result_post_ids ,
            'post_type' => 'product' ,
            'posts_per_page' => $limit ,
            'paged' => $page ,
            'tax_query' => $category_filter , //category
            'orderby' => $order_by,
            'order' => $order
        );
 177 , 176 , ...
$result\u post\u id数组如下所示

array (size=15)
  0 => string '175' (length=3)
  1 => string '148' (length=3)
  2 => string '169' (length=3)
  3 => string '176' (length=3)
  4 => string '170' (length=3)
  5 => string '205' (length=3)
  6 => string '142' (length=3)
  7 => string '168' (length=3)
  8 => string '132' (length=3)
  9 => string '173' (length=3)
  10 => string '177' (length=3)
  11 => string '84' (length=2)
  12 => string '171' (length=3)
  13 => string '128' (length=3)
  14 => string '82' (length=2) 
这是我想要查看的ID顺序,但是当将$args传递给WP_Query()时,会对值上的post ID进行重新排序,这样他会首先显示带有grater值的post,如下所示

$result_post_ids = $wpdb->get_results("SELECT  DISTINCT auction_id 
                   FROM " . $wpdb->prefix . "simple_auction_log 
                   WHERE userid = $user_id 
                   order by date DESC" , ARRAY_N);

  $args = array (
            'post__in' => $result_post_ids ,
            'post_type' => 'product' ,
            'posts_per_page' => $limit ,
            'paged' => $page ,
            'tax_query' => $category_filter , //category
            'orderby' => $order_by,
            'order' => $order
        );
 177 , 176 , ...

但是我想按键的顺序显示
0,1,2
请提前提供帮助并表示感谢。

您应该将
orderby
参数更改为
post\u in

$args = array (
    'post__in' => $result_post_ids ,
    'post_type' => 'product' ,
    'posts_per_page' => $limit ,
    'paged' => $page ,
    'tax_query' => $category_filter ,
    'orderby' => 'post__in',  // Order by the array passed in above
    'order' => $order
);
发件人:

'post\uuu in'
-保留
post\uu in
数组中给出的post ID顺序(从3.5版开始提供)


您应该将您的
orderby
参数更改为
post\u in

$args = array (
    'post__in' => $result_post_ids ,
    'post_type' => 'product' ,
    'posts_per_page' => $limit ,
    'paged' => $page ,
    'tax_query' => $category_filter ,
    'orderby' => 'post__in',  // Order by the array passed in above
    'order' => $order
);
发件人:

'post\uuu in'
-保留
post\uu in
数组中给出的post ID顺序(从3.5版开始提供)


您应该将您的
orderby
参数更改为
post\u in

$args = array (
    'post__in' => $result_post_ids ,
    'post_type' => 'product' ,
    'posts_per_page' => $limit ,
    'paged' => $page ,
    'tax_query' => $category_filter ,
    'orderby' => 'post__in',  // Order by the array passed in above
    'order' => $order
);
发件人:

'post\uuu in'
-保留
post\uu in
数组中给出的post ID顺序(从3.5版开始提供)


您应该将您的
orderby
参数更改为
post\u in

$args = array (
    'post__in' => $result_post_ids ,
    'post_type' => 'product' ,
    'posts_per_page' => $limit ,
    'paged' => $page ,
    'tax_query' => $category_filter ,
    'orderby' => 'post__in',  // Order by the array passed in above
    'order' => $order
);
发件人:

'post\uuu in'
-保留
post\uu in
数组中给出的post ID顺序(从3.5版开始提供)