Wordpress Amateur Hour: Including Twitter alerts in main page
My CSS, PHP, and related web dev skills are, shall we say, impoverished. Because of that, in order to do anything interesting in Wordpress I tend to endlessly search the Web for good how-to’s, and then do a fair amount of my on mucking about in code. I figured I’d document what I learned for both my own future reference and to save some others from the same kind of hunting for tips…
Wordpress Amateur Hour is a mini-series of posts from an amateur’s perspective on tweaking Wordpress and with various plugins and themes. Any solutions I reached, or code I cite, is likely ugly/hacked/inefficient and so on. No guarantees, no best practices here.
First up – adding your latest Twitter ‘tweet’ to your template. It involves a touch of CSS and SimpleTwitter.
Step 1: Download SimpleTwitter
From here. Then upload/activate the plugin in Wordpress. Easy!
Step 2: Configure it
Click on the Options page , enter in your Twitter user name and how often you want SimpleTwitter to check for new updates.
Step 3: Create a style in CSS
This is a bit of formatting I learned from Paul Stamatiou’s great K2 configuration series of posts from a couple years back. Open up your style.css file (if you use the K2 mod like I do, just add this to the CSS file for your ’style’). Here’s what I added to get the effect at the top of this page just below the header (as of March 2008 at least):
/* Alert Style, for use in SimpleTwitter */
.alert {
background: #FFFFFF; /* background color of alert */
border-top: 1px solid #888;
border-bottom: 1px solid #888;
border-left: 0px;
border-right: 0px;
}
Step 4: Insert the code into your template
Open up the file “theloop.php” located in the folder for your theme (inside the wp-content/themes/ folder). Look for the following lines of code:
<!– Start the Loop. –>
<?php if ( have_posts() ) : while ( have_posts()
Just prior to that add:
<p class=”alert”>
<a href=”http://twitter.com/YOURUSERNAME/”>Twittering:</a> <?php get_twitter_msg(); ?>
Make sure you edit the YOURUSERNAME section in order to link back to your Twitter feed. The .alert style also comes in handy for adding special call outs elsewhere in your posts, but that’s a subject for a later edition of the Wordpress Amateur Hour,
Enjoy!















3 Comments
[...] Wordpress Amateur Hour: Including Twitter alerts in main page By Kevin My CSS, PHP, and related web dev skills are, shall we say, impoverished. Because of that, in order to do anything interesting in Wordpress I tend to endlessly search the Web for good how-to’s, and then do a fair amount of my on mucking … Kevin Briody – http://kevinbriody.net [...]
Testing out this here comment function.
[...] Wordpress Amateur Hour Including Twitter alerts in main page Posted by root 8 minutes ago (http://kevinbriody.net) Mar 30 2008 testing out this here comment function leave a comment kevin just spent an hour with the new gas powered weed whacker attacking the Discuss | Bury | News | Wordpress Amateur Hour Including Twitter alerts in main page [...]