Since version 2.9 of WordPress, the platform has supported a technology known as oEmbed that permits the inclusion of rich media in content via a single URL. From WordPress.org, they describe the feature-rich functionality of oEmbed by saying that it is "... a protocol for site A (such as your blog) to ask site B (such as YouTube) for the HTML needed to embed content (such as a video) from site B." It's a means of rendering content I'm not been particularly fond of because there's no easy way of controlling how the data is rendered or cached.
Note: Examples have been removed from this page temporarily. Code remains functional.
Since WordPress version 3.4 , WordPress has supported Twitter embeds into the core of the platform. What this means is that each twitter link on its own line will render as an embedded tweet.
Coder’s wife asks him to pick up a loaf of bread and, if they have eggs, get a dozen. Programmer comes home with a dozen loaves of bread.
— Marty Khoury (@martykhoury) April 10, 2015
The shortcode of
[bmtweet url="https://twitter.com/martykhoury/status/586630176898854913"] returns the following:
Example No Longer Available
The textbox is one that isn't entirely unlike those on this page, although it's just an example and can be formatted to your liking.
Again, the code is just an example. We've used Simple Cache to cache results (may be downloaded as a plugin).
Copy and paste the WordPress function into your theme's
functions.php file or, if you sensibly have one installed, your custom functions plugin.
Used outside of WordPress the following (almost identical) function may be used. Again, Simple Cache is required.
- Making a request to the API yields far more information and permits an almost identical style to that of the Twitter oEmbed response. This article is forthcoming.