<?php $the_query = new WP_Query( array(‘post_type’ => ‘video’, ‘posts_per_page’ => 1, ‘post_status’ => ‘publish’) ); ?>
<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php $url = esc_url( get_post_meta( get_the_ID(), ‘video_oembed’, true ) ); ?>
<?php endwhile; endif;?>
I want that loop should run until it finds a first valid non-empty $url that means as soon as it finds a valid $url the loop should terminate. It should keep running until it finds the first valid non-empty URL.
How should we condition it to get what i want?
N.B. → Loop should work from the latest post to the oldest post.
Read more here:: Customize WordPress loop until it finds a valid Oembed url