How to disable auto-embeds (oEmbed) in WordPress 3.5

WordPress 3.5 will remove some options from the UI. One of these options is the Embeds section.

autoembed_urls, the on-off checkbox, goes way, and oEmbed is always assumed to be on. The only reason to have a UI on/off for oEmbed is if it was easy to accidentally embed items. But it doesn’t parse every link in the post, just those on their own line or inside an [embed] code.

(Andrew Nacin, Ticket #21719)

oEmbed settings in WordPress 3.4

With that there is no visible setting anymore, which let’s you disable the auto-embed function. But, WordPress is not WordPress if it doesn’t provide another way to disable it. Here we go.

The embeds are handled by the WP_Embed class. The constructor of the class registers some actions and filters. Also a filter for the_content:

add_filter( 'the_content', array( $this, 'autoembed' ), 8 );

Now we just need to remove the specific filter again. Since we can’t use $this in the remove_filter call we need to use the global variable $wp_embed which includes the reference to the object.

// Disable auto-embeds for WordPress >= v3.5
remove_filter( 'the_content', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 );

You can add this code to an existing plugin or you can use the small plugin “Auto-embeds Disabler”.

Site note: If you want you can “like” our new Facebook page to get some more WordPress related resources.


Posted

in

by

Tags:

Comments

5 responses to “How to disable auto-embeds (oEmbed) in WordPress 3.5”

  1. Juan Avatar

    i never know and using this function, i dont know how to use it, what this function do at wordpress system?

  2. Dominik Avatar

    Hey Juan,

    with oEmbed you can easily embed media like YouTube or Vimeo. See http://codex.wordpress.org/Embeds for an example and more tricks.

  3. marcel Avatar
    marcel

    thank you for sharing your knowlegde!

  4. Shadab Avatar
    Shadab

    I am using some other plugin to embed the YouTube videos that has more options for customization. Your guide is really helpful to remove the default embed function.

  5. Ahmed Iqbal Avatar

    Hello,

    thanks for this, great tutorial.

    keep it up