wordpress - Remove YouTube embedding with wp_oembed_remove_provider() -


I'm trying to remove YouTube embedding from some of my WordPress output, so it only shows the link.

I have tried the following code without any luck.

  wp_oembed_remove_provider ('#http: // (www)? Youtube \ .com / watch. * # I'); Wp_oembed_remove_provider ('.? #https: // (www \) YouTube \ .com / clock * # i.'); Wp_oembed_remove_provider ('#http: // youtu \ .suggestion /.*# I'); Wp_oembed_remove_provider ('#https: // youtu \ .suggestion /.*# I'); Echo application_filters ("the_content", $ result-> text);  

What am I doing wrong? And how am I doing this correctly?

Chances are that you are at a point where it is too late to remove providers Try hooking in plugins_loaded or init :

  add_action ('init', 'so26743803_wp_oembed_remove_provider'); Function SO26743803_wp_oembed_remove_provider () {wp_oembed_remove_provider ('#https: // youtu.be /.*# i'); // etc}  

Edit (untrade): By setting providers with oembed_providers filter (see):

  Add_filter ('Oembed_providers', 'so26743803_oembed_providers'); Ceremony so26743803_oembed_providers ($ provider) {set ($ providers ['#http: // youtu \ .be /.*# i']); // e.t.c. Return of providers; }  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -