We often use the Oembed function provided by the Wordpress to embed media.
I have a condition where I am running a loop to fetch certain posts from a custom post type, but I want to skip posts in which Oembed is empty.
How to check if Oembed is empty or has a URL in meta of single.php.
I tried something like this →
<?php $url = esc_url( get_post_meta( get_the_ID(), 'video_oembed', true ) ); ?> <?php $embed = wp_oembed_get( $url ); ?>
PHP Needed →
Now how to check if
$embed is empty or not?
Update as requested →
The front end will be like this, and it pulled by running a WP custom loop like this.
But there can be a situation like this where the OEMBED is empty like this.
So what I want is when such situation exists the loop should exclude that post and for that, we need
if condition that checks If oembed is empty or not.