How to Embedd linked content in WordPress !
Usage
To embedd a video or another object into a post or page, place its URL into the content area. Make sure the URL is on its own line and not hyperlinked (clickable when viewing the post).
For example:
Check out this cool video: That was a cool video.
WordPress will automatically turn the URL into a YouTube embed and provide a live preview in the visual editor.
Another option is to wrap the URL in the “embed
” Shortcode.
// NOTE: Remove space between '[' and 'embed' when you try. [ embed width="123" height="456"]http://www.youtube.com/watch?v=dQw4w9WgXcQ[/embed]
If WordPress fails to embed the URL, the post will contain a hyperlink to the URL.
oEmbed
The easy embedding feature is mostly powered by oEmbed, a protocol for site A (such as your blog) to ask site B (such as YouTube) for the HTML needed to embed content from site B.
oEmbed design purpose is to avoid the need to copy and paste HTML from the site hosting the media you wish to embed. It supports videos, images, text, and more.
Does This Work With Any URL?
No, not by default. WordPress will only embed URLs matching an internal whitelist. This is for security purposes.
How Can I Add or Change Support For Websites?
Adding support for an additional website depends on whether the site supports oEmbed.
Adding Support For An oEmbed-Enabled Site
If a site supports oEmbed, you’ll want to call wp_oembed_add_provider() to add the site and URL format to the internal whitelist.
Adding Support For A Non-oEmbed Site
You’ll need to register a handler using wp_embed_register_handler() and provide a callback function that generates the HTML.
Removing Support for An oEmbed-Enabled Site
If you wish to remove an oEmbed-enabled provider, you’ll want to call wp_oembed_remove_provider.
What About oEmbed Discovery?
As of version 4.4, WordPress supports oEmbed discovery, but has severe limitations on what type of content can be embedd via non-whitelisted sites.
Specifically, the HTML and Video content is filtered to only allow links, blockquotes, and iframes, and these are additionally filtered to prevent insertion of malicious content. The HTML is then modified to be sandboxed and to have additional security restrictions placed on them as well.
However, if you feel you are knowledgeable enough to not require this level of safety, you can give unfiltered_html
users (Administrators and Editors) the ability to embed from websites that have oEmbed discovery tags in their <head>
.
The oEmbed discovery content for “link” and “photo” types is not quite so heavily filtered in this manner, however it is properly escaped for security and to prevent any malicious content from being displayed on the site.
How to Embed Linked Content in WordPress
You can easily embed certain types of content in WordPress by simply inserting its URL in your post. You can call this creating a “content card” in your post.
Just paste the whole URL into its own paragraph block. The whole tweet, including images, likes, timestamp, and more will be embedd like this:
The process is the same for YouTube videos. Simply find the video you want to use on YouTube and copy the URL from the top of your browser window:
As well as being great for Twitter posts and YouTube videos, this method also works for many other types of content.