Blog Pile

Customize Your TwitterTools Prefix Text

Do you use the TwitterTools plugin on your own WordPress site to send your blog posts to your tweet stream? Wanna feel like a real WordPress hack jockey? Here is a little code editing you can do without needing to know diddly squat about PHP.

Here’s the thing, when TwitterTools published your new sexy blog post to Twitter, it always prefixes it with the same intro text that everyone else gets:

New blog post: Video of My Big Blah Blah Blah Got Stuck in the Blah… http://tinyurl.com/xxxxx

Do you really want to post like everyone else?

That is so lemming like.

Sheep.

Conformist.

Not for me.

Long ago, I dug into the code and found a line to edit to change it, so my blog posts to twitter are always uniquely mine as Just CogDogBlogged:

just-cogdogblogged

This is so easy, all you need to be able to do is to edit one line of text.

Anyone can do that.

Even you.

Just edit the twitter-tools.php file on line 127 (oh, you likely do not use a decent text editor that gives line numbers (and “doesn’t suck”); it is in section of code following class twitter_tools {) which reads out of the box as:

$this->tweet_prefix = 'New blog post';

All you need to do is to change the text inside the single quotes to be whatever you want your tweets to be prefixed as…. do not delete the ending semi-colon, or your entire blog will die, go up in smoke, and self-destruct… just kidding– but the semi-colon is essentila in PHP to denote the end of a command. Here is how my edited line looks:

$this->tweet_prefix = 'Just CogDogBlogged';

Don’t make it really long as the length of this text takes away from the amount of text in your tweet… the code is smart enough to subtract the exact length if the tweet prefix.

And her is another coders suggestion– print this out and tape to your wall — WORK ON A COPY OF THE ORIGINAL FILE just in case you bork it, you always want to work on a copy, so if something goes wrong you can replace the file on your server with the last working one.

And ahem– this would be a simple feature that could be added to the TwitterTools configuration pane. But I don;t wait for them to do what I want to do if I can hack it.

There you go, a cheap gift from CogDogBlog, make your tweeted blog posts rise among the sea of sameness.

If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
Become a patron at Patreon!
Profile Picture for CogDog The Blog
An early 90s builder of web stuff and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person. And he is 100% into the Fediverse (or tells himself so) Tooting as @cogdog@cosocial.ca

Comments

  1. Ran across this post when looking to add a prefix to the “inbound tweet to blog post”. WP forums were of no help.

    Wonder if you can tell by looking at the code where some simple text could be inserted for either the title or the body that simply stated it was imported by twitter to distinguish between normal blog posts and twitter imports.

    Thanks!

    1. I can only guess since I don’t convert my tweets to post, but you would need to edit line 277, which reads

      , 'post_title' => $wpdb->escape(trim_add_elipsis($tweet->tw_text, 30))

      The value for ‘post_title” is created from the first 30 chararacters from your tweet, so you can try appending text like:

      , 'post_title' => $wpdb->escape(trim_add_elipsis($tweet->tw_text, 30)) . ' (posted from twitter)'

      YMMV

Leave a Reply to Jim Cancel reply

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