I’m currently working on some project that requires me to find a way to publish new posts out of specific Twitter accounts’ tweets. Chandesh Parekh already did most part of the work with his Tweets As Posts plugin, which work very well. But I want it to do a bit more, like automatically add featured images to new posts, or specific formatting, basically making the tweet a quote. Here’s the way.

Install Tweets As Posts

Yes, I’ll suppose you know how to do that.

Configure it

Let’s say I want to create a new post each time Pope Francis says something. Could have been the Barack Obama, it doesn’t matter actually, just pick up the Twitter(s) account(s) you want.


Now there’s something I don’t like: you have to enter at least one hashtag and one username to follow. But I don’t want to follow any hashtag, I just want to publish someones tweets so that my readers who aren’t on Twitter can read them.

Hack it

So the first thing we’re doing is getting rid of this: as long as we provide one username or one hashtag, we’re good. Nothing simpler, we just need to edit the tweets-as-posts-admin.php file, line 42:

if($hashtags !="" && $usernames !="") {


if($hashtags !="" || $usernames !="") {

Now for the rest, we will just wrap the tweets in a <blockquote> tag and add the username after it, along with the date. This time we edit tweets-as-posts-class.php file, starting at line 185:

$new_post["post_content"]    = $item["description_filtered"];


$new_post["post_content"]    = '<blockquote>'.$item["description_filtered"].'</blockquote><p style="text-align: right;">− <a href="'.$item["twitter_username_link"].'">'.$item["twitter_username"].'</a>, '.date( 'd F Y', strtotime( $item["date"] ) ).'</p>';

And right after line 198, we add:

add_post_meta($post_id, $meta_key = "_thumbnail_id", $meta_value = $featured_ID, $unique=TRUE);

where $featured_ID is your chosen featured pic’s ID. Just upload your image using WP media tool and spot the ID on the attachment page. If your attachment page’s URI is http://yout-blog.com/?attachment_id=19, then your ID is 19.

And we’re done, we now have some nice posts relaying Twitter messages.

Publié par Charlie

Être humain depuis 1986, développeur web, designer et photographe, je code pour le Web depuis 2000 et pour WordPress depuis 2008. Aventure, Histoire, sciences, musique, café ou personnages forts en caractère et dotés d'un nez en tout point remarquable sont parmi mes passions les plus dévorantes. Indépendant depuis 2010 je travaille avec des gens formidables dans le monde entier, de la Californie à l'Europe en passant par l'Australie et l'Asie. D'autres détails croustillants ?

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée.