mm

December 10, 2015 WATB Team
Follow me on Twitter

With WordPress 4.4 came a raft of improvements, including a new oEmbed feature. In their own words:

“Starting with version 4.4, WordPress becomes an oEmbed provider as well, allowing any oEmbed consumer to embed posts from WordPress sites….”

“…this new feature means that any post (or basically any public post type) will now be embeddable. If you’re using pretty permalinks, the embeddable content will be available at example.com/your-post/embed/.”

For most WordPress users this is great, and it’s not a feature we want to remove. You can if you insist by using this plugin.

However, if like us, your main concern was more JS in your site’s header, you can use these actions to move the code that this feature inserts into your site’s footer instead:

// Remove oEmbed discovery links from header and place in footer
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
add_action( 'wp_footer', 'wp_oembed_add_discovery_links' );

// Remove oEmbed-specific JavaScript from the front-end and back-end header and place in footer
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
add_action( 'wp_footer', 'wp_oembed_add_host_js' );

We haven’t tested whether this maintains the functionality however, so use at your own risk.

Looking for more tips?

Jump on our mailing list & get digital goodness straight to your inbox; including helpful tips, tricks and the latest articles surrounding marketing, web design and branding.

Sign up →