Having your tweet and embedding it, too

One of things that WordPress has been doing well for years now is embedding tweets (and other media) automagically: You simply copy the URL, and WordPress will convert it into a handsomely formatted tweet. A number of plug-ins developed for that purpose have become obsolete for the same reason, but there are problems for anyone who writes posts (or tweets) not intended to be immediately disposable: If Twitter changes its API or, as also occurs, a quoted tweep’s account disappears, the embedded content may disappear along with it.

It’s easy, as I just discovered today, to have your tweet and embed it, too, and in a way that should, as we say, “degrade gracefully.” Automating this process in the form of a plug-in would not be terribly difficult, though I’m not sure how many WordPressers care enough about their posts or the tweets they embed in them to use it.

Until such time as a “keep tweet-text” plug-in is developed or the capacity is made part of WordPress core functionality (don’t hold your breath), you can use the following 4-step procedure.

1. Embed the tweet as you normally would

Copy the tweet URL, and place it on its own line in the Visual or Text editor, save the files as a draft, and preview it.

2. View Page Source

On Firefox, that means right-clicking on the rendered (previewed) post, and choosing View Page Source from the contextual menu.

3. Search for “twitter-tweet” in the Page Source window

That’s the CSS class that WordPress adds to the automagic embed. You will find code that looks something like the following  in your “post-entry” div:

<blockquote class="twitter-tweet" width="550"><p>What exists now is domestic &amp; international momentum to finally address the larger Syrian conflict, and not just the limited problem of ISIL</p>
<p>&mdash; Zeddonymous (@ZeddRebel) <a href="https://twitter.com/ZeddRebel/statuses/504680520933212161">August 27, 2014</a></p>
<p><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script></p>

4. Copy-paste the lines from the first <blockquote to the last /p> into the text editing pane – and save.

I’m using the tweet that I was reading when I stumbled upon this method. The above will get you the following render, which will be identical to the tweet auto-embedded by its URL alone:

Which, through the magic of twitter’s Javascript, is the same pretty, functional dealybob that the auto-embed gets you, with the difference being that, in the event the tweet or tweep disappears from Twitter, or for that matter in the even that Twitter goes down – or if you’re exporting the post to a different format or platform – you’ll still have the content you were using, converted into a simple blockquote:

For the purposes of illustration, I’ve changed the tweet (or “status” in Twitter nomenclature) to a non-existent one. If you click on the link, it will take you to a “sorry, that page doesn’t exist” page.

(Note usual cautions about Text vs Visual editor on WordPress: If you return to the Visual Editor, you may lose the key line that calls the Twitter script at the end – meaning that you should do this step last, and be careful when returning to the post at a later time.)

Commenter Ignore Button by CK's Plug-Ins

Leave a Reply

Your email address will not be published. Required fields are marked *