How To: Adjust “Twitter Tools” Prefixing

Twitter Tools is an awesome plugin. I use it on multiple sites, including this one, to automatically tweet new posts.

While the “New blog post:” prefix is good for this site where I also do tweets of my own, it’s not so good for Twitter accounts that are only used for tweeting new posts, such as my FinalGear.com Twitter account. So here’s a tiny little plugin that will allow you to change or remove the prefix from the tweets that Twitter Tools makes.

<?php /*

Plugin Name:  Twitter Tools Tweaks
Description:  Makes modifications to the automatic tweet format of the &quot;Twitter Tools&quot; plugin.
Author:       Viper007Bond
Author URI:   http://www.viper007bond.com/

*/

add_action( 'init', 'TwitterToolsTweaks', 15 );

function TwitterToolsTweaks() {
	global $aktt;

	// Some examples of what you can do that have been commented out by "//".
	// Remove the slashes from the beginning of the line to enable that line.

	// Changes the prefix
	// $aktt->tweet_prefix = 'Check out my cool blog post';

	// Changes tweet format to: "PREFIX: URL - TITLE"
	// $aktt->tweet_format = $aktt->tweet_prefix . ': %2$s - %1$s';

	// Changes tweet format to: "TITLE URL"
	// $aktt->tweet_format = '%1$s %2$s';
}

?>

Copy/paste the above into a text file (enable plain text mode first if need be) and then rename it to something.php (twitter-tools-tweaks.php will do) and stick it in your plugins folder. Activate it and you’ll be good to go.

13 thoughts on “How To: Adjust “Twitter Tools” Prefixing

  1. Viper, When I comment out the slashes activation of the plugin triggers “fatal error” on that edited line. ???
    Why not just edit line 171 in the twitter tool php file?

  2. Pingback: Twitter Updates for BuildingOnlineBiz.com

  3. Alex,

    Thanks for the great entry and I like your approach.

    Any suggestions on how to add a prefix to the post_title within Twitter Tools? I’d like the title for my tweets to be appended with something like “Twitter Feed:” when they appear in WP.

  4. Pingback: I just optimized my #wordpress… | Intesyo

  5. this no longer works. i uploaded the plugin and it worked great until I kept getting an upgrade notice. Once I upgrade, the plugin disappears. and goes back to the prefix.

    No dice on this one. Looks like Alex pulled a fast one.

      • actually, i dont think that the UI lets us remove the prefix entirely. I would like to have it take my blog title, for example, The Blue Man Jumped Off The Wheel. But if I update the plugin, it removes your plugin and then the prefix comes back as:
        : The Blue Man Jumped Off the Wheel

        I dont want any extra characters. So to make this work, I have to leave your plugin there and not update for now.

Leave a Reply to ILLIONAIRE Cancel reply