有两种解决方案:
1。确保所有帖子都设置了该字段
您可以轻松做到这一点-只需使用
save_post
钩住并将其设置为默认值。(您还应该为尚未设置该字段的现有帖子添加默认值。)
2。使用稍加修改的查询
$faqArgs = array(
\'post_type\' => \'faq\',
\'meta_key\' => \'faq-order\',
\'order\' => \'ASC\',
\'orderby\' => \'meta_value_num\',
\'meta_query\' => array(
\'relation\' => \'OR\',
array(
\'key\' => \'faq-order\',
\'value\' => \'bug #23268\',
\'compare\' => \'NOT EXISTS\'
)
)
);
$faq = new WP_Query($faqArgs);