我有一个值为1和0的自定义字段,我希望在一个帖子类型的数组中,那些值为1的帖子位于该类型中,其他帖子位于其下方。有可能吗?
Post to Top in Array
1 个回复
SO网友:Cesar Henrique Damascena
你当然可以,只要按meta_field
, 就像这个例子
$posts = get_posts(array(
\'post_type\' => \'post_type\', //The slug of your post type
\'posts_per_page\' => -1,
\'meta_key\' => \'meta_key\', // The name of your field
\'orderby\' => \'meta_value_num\',
\'order\' => \'DESC\' // Will put the higher values first
));
在中了解更多信息Documentation.结束