Display Yoast meta-description `wpseo_desc` within loop of categories and fail silently if no data is set [closed]

You can just check if $meta and $meta_desc exist. If not, don’t echo anything.

$popular_topics = get_field('popular_topics');

if ( $popular_topics ) : 

    foreach ( $popular_topics as $topic ) : 

        $id = $topic->term_id;
        $meta = get_option('wpseo_taxonomy_meta');

        if ( $id && ( $meta && !empty($meta) ) ) : 

            $meta_desc = $meta['category'][$id]['wpseo_desc'];

            if ( $meta_desc ) : ?>

                <p class="my-paragraph">
                    <?php echo esc_html( $meta_desc ); ?>
                </p>

                <?php

            endif;

        endif;

    endforeach;

endif;

tech