我正在编写一个wordpress代码,如下所示modified post displays at the top.
$temp_args = [
\'post_type\' => array(\'current-channel\', \'post\', \'current-episodes\'),
\'post_status\' => \'publish\',
\'orderby\' => array(
\'feat_yes\' => \'ASC\',
\'post_type\' => \'ASC\',
\'modified\' => \'DESC\',
\'date\' => \'DESC\'),
\'posts_per_page\' => $data->{"no_articles_" . ICL_LANGUAGE_CODE},
\'tax_query\' => [
[
\'taxonomy\' => \'category\',
\'field\' => \'term_id\',
\'terms\' => $cat_today,
],
],
];
$q = new WP_Query($temp_args);
此时,按以下方式进行订购:
\'orderby\' => array(
\'feat_yes\' => \'ASC\',
\'post_type\' => \'ASC\',
\'modified\' => \'DESC\',
\'date\' => \'DESC\'),
Problem Statement:
我想知道我应该在上面的代码中做些什么更改,以便
sticky posts are displayed at the top before the regular post.
订单应该是这样的sticky post should be always at the top 然后all the regular post
SO网友:admcfajn
我想您可能需要添加feat_yes
作为meta_key
$temp_args = [
\'post_type\' => array(\'current-channel\', \'post\', \'current-episodes\'),
\'post_status\' => \'publish\',
\'meta_key\' => \'feat_yes\',
\'orderby\' => array(
\'meta_value_num\' => \'ASC\', /* or \'meta_value\' */
\'post_type\' => \'ASC\',
\'modified\' => \'DESC\',
\'date\' => \'DESC\'),
\'posts_per_page\' => $data->{"no_articles_" . ICL_LANGUAGE_CODE},
\'tax_query\' => [
[
\'taxonomy\' => \'category\',
\'field\' => \'term_id\',
\'terms\' => $cat_today,
],
],
];
$q = new WP_Query($temp_args);
以下是一些相关链接: