问题是你在循环阶段过滤,而不是在查询阶段。发生的情况如下:
WP_Query
, 给我最新的两本书book_featured
, 因此,只有在显示
的情况下,才能将
if ( book_featured )
来自循环的条件(&A);将其添加到查询中:
$args = array(
\'post_type\' => \'book\',
\'posts_per_page\' => \'2\',
\'meta_key\' => \'book_featured\',
\'meta_value\' => \'1\', // I\'m not 100% sure this is how ACF stores checkbox data, you\'ll need to check the `wp_postmeta` table
);