Query pages for use of a flexible content layout

I posted this on the ACF support forum as well and got great feedback: https://support.advancedcustomfields.com/forums/topic/query-pages-for-use-of-a-flexible-content-layout/

With a bit of tweaking, it worked. Here’s what I ended up with:

<?php
    $flex_content_name="flexible_content";  // < update with applicable field name
    $layout_name="featured-resources";  // < update with applicable subfield name
    $args = array(
        'posts_per_page'    => -1,
        'post_type'     => 'page',
        'meta_query'    => array(
            array(
                'key'       => $flex_content_name,
                'value'     => '"'.$layout_name.'"',
                'compare'   => 'LIKE'
            )
        )
    );

    $the_query = new WP_Query( $args );
?>

<?php if( $the_query->have_posts() ): ?>

    <ul>
    <?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
        <li>
            <a href="https://wordpress.stackexchange.com/questions/332605/<?php the_permalink(); ?>">
                <?php the_title(); ?>
            </a>
        </li>
    <?php endwhile; ?>
    </ul>

<?php else : ?>
    <p>No matches.</p>
<?php endif; ?>

<?php wp_reset_query(); ?>