Extract links inside embed tags in WordPress

No need to use regex. WordPress has a handy function to strip shortcodes from a string. Use strip_shortcodes( $content ). So in your case, $content = “”; $your_clean _url = strip_shortcodes( $content ); echo $your_clean_url; // should output https://www.youtube.com/watch?v=Z9QbYZh1YXY EDIT Here’s a function (tested) that will remove your “unwanted” shortcode, and any other one. function … Read more

Get youtube link title in post title

Use the following code into your functions.php file. function change_title_yt( $post_id ) { $current_title = $_POST[‘post_title’]; $doc = new DOMDocument(); $doc->preserveWhiteSpace = FALSE; $doc->loadHTMLFile($current_title); $title_div = $doc->getElementById(‘eow-title’); $title = $title_div->nodeValue; $my_args = array( ‘ID’ => $post_id, ‘post_title’ => $title ); if ( ! wp_is_post_revision( $post_id ) ){ // unhook this function so it doesn’t loop … Read more

WordPress and Youtube problem

Try embedding an iFrame. Go to the youtube video you’re trying to post. Click right > Copy embed code. Paste it in the HTML editor on wordpress. It should work without a plug in.

Block editor: Sandbox iframe shows outdated HTML

The WordPress (Gutenberg) block editor requests data from an oembed proxy endpoint, and that endpoint retrieves data using the Transients API. It seems that clearing all oembed caches doesn’t also clear oembed transient caches. The following database query to clear your oembed caches from the postmeta table is NOT sufficient: global $wpdb; $meta_key_1 = “|_oembed|_%%”; … Read more

Can’t embed certain youtube videos into theme

I had recently similar issue with Divi and embedding videos. At the end I realized its because oEmbed issues in WordPress sites running on host with both IPv4 and IPv6 sites. Either you can add this code to your functions.php to fix this: add_action( ‘http_api_curl’, function( $curl_handle ) { curl_setopt( $curl_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); }); … Read more