Tag Archives: Twitter

Better Twitter Integration

I both love and hate the Twitter-Tools plugin for WordPress.

On one hand; I really like how it can integrate Twitter into my blog via both sidebar widget and weekly Twitter digest posts… But, on the other hand, I was really starting to feel like these digest posts were cluttering up both my blog and my archives. Several times recently I have found myself scrolling back through way too many Twitter digest posts in order to get at my ACTUAL blog posts and content that I had written. Basically, I came to the conclusion that “I didn’t like this” and I had to modify how Twitter integrated with my Blog.

Today I’ve taken the steps necessary to achieve what I believe is the best of both worlds. I now have weekly Twitter digest post created as usual; but they do not display in my main blog page or in my archives page — AND you have to specifically navigate to a “Twitter” page in order to see them at all.

This was actually a little more challenging for me than I’d like to admit – but I’ll go through the steps below:

First: Exclude the Category
To block out my Twitter category from displaying on my blog and archives, I added the following function to the functions.php file within my theme directory. The “-28” below refers to the corresponding category ID for the Twitter category. This code made it so all posts within the “Twitter” category are ignored in both my blog page and my archives.

function exclude_category($query){
if ($query->is_home) {
$query->set('cat', '-28');
}
return $query;
}
add_filter('pre_get_posts', 'exclude_category');

Second: Make the Category “Navigateable” from the Main Page
The more challenging part for me was figuring out an “easy” way to navigate to these Twitter digest posts. It sounded like a fairly easy thing to do; but I had a surprisingly difficult time with it.

I experimented with some .htacces redirection, and also some plugins that claimed to do exactly what I wanted (but, sucked). In the end; I chose to just modify my theme’s main loop logic and save it as a new page template. I copied the the text from my theme’s index.php file, and and pasted it into my a file called “twitter.php” which I saved as a new page template. I then replaced the following code:

if (have_posts()) :
while (have_posts()) : the_post();

With this code:
$recent = new WP_Query();
$recent->query('cat=28');
if ($recent->have_posts()) :
while($recent->have_posts()) : $recent->the_post();

This actually worked fairly well, and in retrospect is very easy – it just took me quite awhile to arrive at this solution! The final step here was then to add a page called “Twitter” via the administration panel; and simply change the page to use this Twitter.php template instead of the default page template.

Voila, a Twitter page that you can navigate to which displays all the weekly digest Twitter posts created automatically by the Twitter Tools plugin.

**** UPDATE ****
Vanlandw had a great recommendation about excluding these Twitter digest posts from my RSS feeds as well. That was very simple to do… My exclude function in the functions.php file in my theme directory now reads as such:
function exclude_category($query){
if ($query->is_home || $query->is_feed) {
$query->set('cat', '-28');
}
return $query;
}

And, now the Twitter digest posts are excluded from my RSS feed as well! 🙂 WordPress and PHP are both awesome.

The Twitter Enigma

Love it or hate it, Twitter is really a pretty amazing thing.

I’ve been using twitter for a little over a year now, and I’ve gone through phases ranging from daily use to weeks without tweets. Overall, I’m a fan and I think it’s a “cool” technology.

Granted you’re always going to have the annoying too much information or 100-tweets-a-day type of annoyances that really nobody likes. But, you also can really do some cool things.

Example 1
I posted a “tweet” regarding my frustration at Best Buy for canceling my order for a $9.99 52” television. CNN reporter Abbi Tatton, searching Twitter, finds my tweet and looks up my contact information. I am then interviewed and referenced on a CNN airing of “The Situation Room” and also countless online news sites that seemingly feed from CNN. A mild 15 minutes of fame that is then followed up by a radio interview about the whole situation. The entire thing started because I posted a tweet – and that is just amazing to me.

Example 2
Yesterday I had a pretty creative idea for Google Voice, a service I have been happily using for about 6 months now. I thought it would be pretty cool if Google Voice had the capability to set a wakeup call. This would be set just like any other alarm, and then maybe even have the wakeup call go to different phones on different days.

Surprised at myself for actually coming up with a good idea, I post a tweet directly to Craig Walker (co-founder of GrandCentral and top dog at Google Voice now) about the wakeup call idea.

He replies: “@vanberge love this idea”

So, very possibly this functionality may actually make it into Google Voice some point down the road… All because of Twitter. I was able to directly pitch an idea to the person that can do the most with it. Simply amazing.

Like I said – love it or hate it, Twitter makes some pretty cool things possible. Here’s to hoping for a wakeup call functionality to show up soon under my Google Voice settings page.