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

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.

Verified to Work with Thesis Theme 1.8! Enjoy!

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 //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 //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 twitter_before_content() {
  if (is_home()) { ?>
  

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 @thotsunlimited or in case you face any issues with setting this up on your Thesis Blog. I would love to help!

If you link this entry, please share it
We Recommend
Make your Wordpress Site doubly awesome, we recommend the usage of Genesis Framework based Child Themes that are SEO Rich, Customizable and Highly Reliable. Click here to know more

Comments

  1. Matt Langford says:

    Nice tut! I especially like the highlighted tweet from some dude named @Matt425!

  2. Thanks Matt! Yeah @Matt425 is a cool friend of mine =)

  3. Avinash d'Souza says:

    This doesn;t seem to be working for me Ashwin…the gif just refuses to show up. Also, the formatting isn't kicking in like on your blog….

  4. Avinash,

    A couple of questions – are you using the code as is or done some changes. If yes, can you send me the code that you use.

    Also a link to your Blog would be appreciated. Let me just take a look.

  5. Avinash d'Souza says:

    Very strange…but it works like a charm now. Probably because I deleted all the other code… :-)

    Need a bit of help in styling though…need the “Join me on Twitter” link on the same line as the number of days. Firebug testinf isn't letting me move the twitter link div up past a point.

    Also, is there anyway of giving the entire widget a background and a border?

    Still in sandbox mode so no link…

  6. For showing the 'Join' link on the same line as the time (or days) – use the following:

    /custom/images/tipicon-medium.jpg” align=”left” style=”border:none;vertical-align:center;” width=”30″ height=”45″/>
    Have a Tip for all Bloggers and Social Media Users out there? /contact”>Contribute and be featured on the sidebar of this Blog (with a do-follow link to your Blog/Website of course!)




    • " rel="nofollow">http://twitter.com/javascripts/blogger.js'>
      " rel="nofollow">http://twitter.com/statuses/user_timeline/tublogger.json?callback=twitterCallback2&count=1'>



    and the CSS:

    #twitter_link_new {
    color:#2A69A3;
    text-decoration:none;
    font-size:1em;
    font-style:italic;
    float:right;
    margin-top:-15px;
    padding-right:20px;
    }

    Actually negative margin will do the trick…

  7. You can apply background and the border styles to the CSS element:

    #twitter_div

    This will spruce up your Twitter box!

  8. John says:

    I followed this code exactly and it works in Firefox 3, but breaks my homepage in IE8.

    Any ideas?

  9. Hi John,

    Thanks for letting me know. I will check it later in the day on IE8 and let you know is something needs a change.

  10. John says:

    thanks. fyi, I am running your tut on Thesis 1.6 which was just released today.

  11. John says:

    Hi Ashwin… any luck?

  12. Hi John,

    No complete solution yet – I had set it up on my sandbox site – https://thoughtsunlimited.net/apps/sandbox/

    Works good on FF, Safari and Chrome and older IE. Breaks only on IE8. Few observations:
    - Problem is caused by

    I am still looking to find a workaround… Will let you know once I have something

  13. John says:

    Thanks for looking into it, glad it's not my imagination. Hope you figure it out soon, this is an awesome mod.

  14. Thanks John. I will surely let you know if I solve the problem :)

  15. Alexandru says:

    Hy!

    How can i actually show this on another page other than home.Let's say about page?
    Replacing if (is_home()) with what?

    tks

  16. Hi Alexandru,

    To display on Single Posts (and not home page) – if (is_single())

    To display on all Pages (non Posts) – if(is_page())

    To display on specific Page – if(is_page('2'))

    Here '2' is the Page id. You can go to WP Dashboard->Pages and hover the mouse over the Page name. On the status bar you can see the Page id there.

    To use a combination – show in Single Posts and Page with id=2,

    if (is_single() || is_page('2'))

    This also would work.

    Let me know if you want to know more…

  17. John says:

    any luck?

  18. John says:

    fyi, if I remove >" rel="nofollow">http://twitter.com/javascripts/blogger.js'>> from the custom functions and then reload, it does not break IE8, but it is not showing the tweet. So it has to be related to that java code, yes?

  19. Yes even i found that the issue is with Javascript. Refer to the my earlier chain of comments:

    - Problem is caused by

    So this API is out of our hands! :(

  20. juanbravo says:

    hey man, how to add some gray background here? thank you..

  21. You should be able to do it – by tweaking the '#twitter_div' CSS element.

    right now the background element is:

    background:transparent url(images/twitter_verysmall.gif) no-repeat scroll 0 10px;

    here you should be able to replace 'transparent' with the 'hex color code' to get the background.

    Let me know if it works.

  22. juanbravo says:

    that's working, but the link to subscribe is not had the background…
    i want the link to subscribe is also have the same background.. thank you before

  23. shamrock says:

    Can I run this in a exec php widget on wordpress?

  24. Yes in Theory you should be able to do it. Let me know if it did not work.

  25. Yes in Theory you should be able to do it. Let me know if it did not work.

  26. manavecplan says:

    Hi Ashwin,

    Quick question here…what would be the css to move the day count (eg. 14 mins ago) to the same line as the status? Thnx…

  27. The link you specific actually comes from Twitter API.

    The best I think is to tweak with this CSS.

    #twitter_div li span a { … }

    I don't have the exact code yet – but a float:right; and a top negative margin should help.
    Let me know if it works.

    Thanks.

  28. manavecplan says:

    Nope…that didn't quite work out. :-(

  29. Let me try it this weekend on my sandbox and let you know. Thanks.

  30. manavecplan says:

    Thanx a ton Ashwin…much appreciated as always!

  31. Rodelio Lagahit says:

    after loading the codes in the custom_functions I got this error “Parse error: syntax error, unexpected '?' in /home7/diwanagc/public_html/jobgrand/wp-content/themes/thesis_17/custom/custom_functions.php on line 34″

    what did i miss? just copied the code and edit only ***yourtwitter*** nothing more nothing less…

  32. Ashwin says:

    @Rodelio

    Can you try this code instead? The code in the post has some character escapes, which are removed here…

    /* Latest Tweets above Content column */
    function my_thesis_before_content() {
    if (is_home()) { ?>





    • " rel="nofollow">http://twitter.com/javascripts/blogger.js'>
      " rel="nofollow">http://twitter.com/statuses/user_timeline/**yourtwitter**.json?callback=twitterCallback2&count=1'>





    }
    }
    add_action('thesis_hook_before_content', 'my_thesis_before_content');
  33. Rodelio Lagahit says:

    Thanks! worked like a charm.. but gotta catch the twitter bird coz it's missing.. :) once again, thank you!

  34. Max says:

    Hey Ashhwin,

    For some reason, all I see is the half Twitter bird and no tweet. Can you please let me know what the problem might be?

  35. Ashwin says:

    Max,

    Whenever the Twitter API down or non-responsive – and there is no tweet to show – only half of the Twitter bird is shown…

    Can you check if this happens all the time?

  36. Puppies for Sale says:

    As a new user of Twitter, this tutorial will help me a lot. I will surely follow your instructions.

  37. rys says:

    you can also refer to this site on how to display your latest tweets using twitter API
    as easy as 1 2 3..

    http://www.ryscript.co.cc/web/how-to-display-la…

    thanks

  38. Jorge Ledesma says:

    Just tried it again, simply copy and paste into custom.php and not working FYI, thanks looking forward to see it working

Trackbacks

  1. Ashwin says:

    Show your latest Tweet on top of Content Column in Thesis Theme http://bit.ly/KxI4P #thesiswp

    Reply
  2. Ashwin says:

    @pearsonified @diythemes Show your latest Tweet on top of Content Column in Thesis Theme http://bit.ly/KxI4P

    Reply
  3. Ashwin says:

    Show your latest Tweet on top of Content Column in Thesis Theme http://bit.ly/2zaRvu

    Reply
  4. WordPress wptop50.de says:

    By @-tublogger Show your latest Tweet on top of Content Column in Thesis Theme http://bit.ly/KxI4P #thesiswp #-WordPress

    Reply
  5. Ashwin says:

    Show your latest Tweet on top of Content Column in Thesis Theme http://bit.ly/HL6ng

    Reply
  6. Show your latest Tweet on top of Content Column in Thesis Theme — Thesis Press Visual Guides says:

    [...] Read the rest of the story… [...]

    Reply
  7. Michael Totten says:

    Great #thesis tutorial for adding twitter: http://bit.ly/TkGoz

    Reply
  8. yamasas says:

    [twitter] Show your latest Tweet on top of Content Column in Thesis Theme http://bit.ly/5vfS5N

    Reply
  9. 47 Customizations for the Thesis Theme says:

    [...] Show Your Latest Tweet on Top of Content Column in Thesis Theme Learn how to display your latest Tweet in a prominent spot on your blog. [...]

    Reply
  10. Ashwin says:

    Show your latest Tweet on top of Content Column in #thesiswp Theme – http://bit.ly/dnsaRF #wordpress

    Reply

Speak Your Mind

*