我猜在get_option( \'sticky_posts\' )
是粘贴的帖子数组吗?我建议将此方法更改为发布元数据。
例如,您可以通过向新闻添加post meta来将新闻标记为粘性新闻add_post_meta($post_id, \'sticky_post\', 1);
然后你应该按此元排序帖子:
$args = array(
\'post_type\' => \'news\',
\'meta_query\' => array(
\'relation\' => \'OR\',
array( // get posts with sticky_key value = 1
\'key\' => \'sticky_post\',
\'value\' => \'1\',
),
array( // get posts with sticky_key value != 1, so this is rest of posts
\'key\' => \'sticky_post\',
\'value\' => \'1\',
\'compare\' => \'!=\'
)
),
\'orderby\' => array(
\'meta_value_num\' => \'DESC\', // first order by sticky_post value, so you could create levels of "stickness"
\'post_date\' => \'DESC\' // then normal sort
)
);
$query = new WP_Query($args);