WordPress Loop trouble with ACF [closed]

The trouble is you’re filtering at the loop stage, not the query. Here’s what’s happening:

  • WP_Query, give me the latest 2 books
  • Loop over them
  • Only one has book_featured, so only that shows

Instead, remove the if ( book_featured ) condition from your loop & add it to your query:

$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
);

error code: 523