Show your latest Tweet on top of Content Column in Thesis Theme

by Ashwin on September 15, 2009

in Thesis Theme, Wordpress

Thesis Theme makes life a lot simpler, if you are trying to customize your blog.  In this post, I will show you how to display your latest tweets at the top of your content column.  You can either choose to display this only on the Home page or on all pages.

What we will Create?

This is what we are trying to create in this tutorial – the latest twitter update on the top of your content column.  There is also a link to your Twitter profile home page.

thesistwittertop_1


How do we get this?

As with any other customization in Thesis Theme, this requires changes in the following files found under the <Wordpress Root>/<Thesis theme folder>/custom folder.

  • custom_functions.php
  • custom.css

Changes in custom.css

Copy the following code into your custom.css file towards the bottom.  I have suitably demarcated the code with a comment, so that you can easily identify it later.

/* Twitter widget Before content */
#twitter_div {
  background:transparent url(images/twitter_verysmall.gif) no-repeat scroll 0 10px;
  padding:10px 0 10px 48px; position:relative;
}
#twitter_div li {
  font-family:georgia,serif;
  font-size:1em;
  font-size-adjust:none;
  font-stretch:normal;
  font-style:normal;
  font-variant:normal;
  font-weight:normal;
  line-height:normal;
  list-style-image:none;
  list-style-position:outside;
  list-style-type:none;
}
#twitter_div li span {
  display:block;
  font-size:1.1em;
  font-style:italic;
}
#twitter_div ul {
  margin:0 0 8px 12px;
}
#twitter_div li span a a:visited {
  color:#2A69A3; text-decoration:none;
}
#twitter_link {
  color:#2A69A3;
  text-decoration:none;
  font-size:1em;
  font-style:italic;
  float:right;
  margin-right:25px;
}
/* Twitter widget Before content */ 

I have used a very small Twitter icon that displays on the left corner.  You can download the icon from here (right click and ‘Save as’).

twitter_verysmall

Copy this file into your <Wordpress Root>/<Thesis theme folder>/custom/images folder.

Changes in custom_functions.php

Now copy the following code into your custom_functions.php file.  This code uses the ‘thesis_hook_before_content’ of Thesis.  So if you are already using this Hook in your Thesis Customization, just add only the HTML portion of this code towards the end (if you have any problems, feel free to contact me).

/* Latest Tweets above Content column */
function my_thesis_before_content() {
  if (is_home()) { ?&gt;
   &lt;div class='format_text'&gt;
      &lt;div id='twitter_div'&gt;
        &lt;ul id='twitter_update_list'&gt;
	  &lt;li&gt;
		&lt;script type='text/javascript' src='http://twitter.com/javascripts/blogger.js'&gt;&lt;/script&gt;
		&lt;script type='text/javascript' src='http://twitter.com/statuses/user_timeline/**yourtwitter**.json?callback=twitterCallback2&amp;amp;count=1'&gt;&lt;/script&gt;
	  &lt;/li&gt;
	&lt;/ul&gt;
        &lt;div id='twitter_link'&gt;
		&lt;a href='http://twitter.com/**yourtwitter**'&gt;Join Me on Twitter&lt;/a&gt;
	&lt;/div&gt;
       &lt;/div&gt;
   &lt;/div&gt;
&lt;?php
  }
}
add_action('thesis_hook_before_content', 'my_thesis_before_content');

In the above code, there are a couple of points where it is mentioned as **yourtwitter**. Replace them with your Twitter username.

Current Code as is, would display the Twitter updates only on your home page. If you want this to be displayed on all other pages and posts, just remove the following

  • if (is_home()) from the top
  • } from the bottom

Tip: For the sake of this tutorial, I have used the thesis_hook_before_content hook. But you can easily replace with other hooks like thesis_hook_before_post_box, thesis_hook_before_post, thesis_hook_after_post, thesis_hook_after_post_box, etc., depending on where you need the Twitter updates to appear. Love the power of Thesis!

Conclusion

And, that’s it. Now just reload your page and see your latest tweet right there at the top. Contact me @tublogger or ashwin.chandrasekaran@gmail.com in case you face any issues with setting this up on your Thesis Blog. I would love to help!

  1. Search Box in Navigation Bar of the Thesis Theme
  2. Control Home Page Post Excerpt Content in Thesis Theme
  3. Create a Killer Services and Portfolio Page with Thesis Theme
  4. Thesis Theme : Setup Pagination on Home Page
  5. Create a Full-Height Sidebar and Full-Width Navigation Menu in Thesis Theme
blog comments powered by Disqus

Previous post:

Next post: