多个Orderby无法正常工作

时间:2016-12-23 作者:user3391949

我想对包含meta键“featured\\u blog”和日期的帖子进行优先排序。订单运行不正常。设置是每个类别页面的顶部都有博客,然后是普通页面。

$args = array(
                \'posts_per_page\'    => 10,  
                \'post_type\'         => \'post\',
                \'cat\'               => $category->cat_ID,
                \'paged\'             => $paged,                  
                \'orderby\'           => array(
                                        \'orderby\'  => array(\'meta_value_num\' => \'DESC\', \'date\' => \'DESC\' ),
                                        \'meta_key\' => \'featured_blog\'
                                    )
            );  

1 个回复
SO网友:Tunji

你的orderby 是错误的,应该是

$args = array(
    \'posts_per_page\'    => 10,
    \'post_type\'         => \'post\',
    \'cat\'               => $category->cat_ID,
    \'paged\'             => $paged,
    \'meta_key\'          => \'featured_blog\',
    \'orderby\'           => array(\'meta_value_num\' => \'DESC\', \'date\' => \'DESC\' ),

);

相关推荐

I receive taxonomy id

您好,我想从字段中获取值,但我收到的id代码如下:function add_product_column( $columns ) { //add column $columns[\'new_column\'] = __( \'New column\', \'woocommerce\' ); return $columns; } add_filter( \'manage_edit-product_columns\', \'add_pr