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.
How do we get this?
As with any other customization in Thesis Theme, this requires changes in the following files found under the
- 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’).
Copy this file into your
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()) { ?>
Join Me on TwitterIn 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!
Nice tut! I especially like the highlighted tweet from some dude named @Matt425!
Thanks Matt! Yeah @Matt425 is a cool friend of mine =)
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….
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.
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…
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'>
http://twitter.com/tublogger'; rel=”nofollow”>Join Me on Twitter
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…
You can apply background and the border styles to the CSS element:
#twitter_div
This will spruce up your Twitter box!
I followed this code exactly and it works in Firefox 3, but breaks my homepage in IE8.
Any ideas?
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.
thanks. fyi, I am running your tut on Thesis 1.6 which was just released today.
Hi Ashwin… any luck?
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
Thanks for looking into it, glad it's not my imagination. Hope you figure it out soon, this is an awesome mod.
Thanks John. I will surely let you know if I solve the problem
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
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…
any luck?
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?
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!
hey man, how to add some gray background here? thank you..
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.
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
Can I run this in a exec php widget on wordpress?
Yes in Theory you should be able to do it. Let me know if it did not work.
Yes in Theory you should be able to do it. Let me know if it did not work.
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…
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.
Nope…that didn't quite work out.
Let me try it this weekend on my sandbox and let you know. Thanks.
Thanx a ton Ashwin…much appreciated as always!
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…
@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'>
http://twitter.com/**yourtwitter**'; rel=”nofollow”>Join Me on Twitter
}
}
add_action('thesis_hook_before_content', 'my_thesis_before_content');
Thanks! worked like a charm.. but gotta catch the twitter bird coz it's missing.. once again, thank you!
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?
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?
As a new user of Twitter, this tutorial will help me a lot. I will surely follow your instructions.
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
Just tried it again, simply copy and paste into custom.php and not working FYI, thanks looking forward to see it working
Trackbacks
Show your latest Tweet on top of Content Column in Thesis Theme http://bit.ly/KxI4P #thesiswp
@pearsonified @diythemes Show your latest Tweet on top of Content Column in Thesis Theme http://bit.ly/KxI4P
Show your latest Tweet on top of Content Column in Thesis Theme http://bit.ly/2zaRvu
By @-tublogger Show your latest Tweet on top of Content Column in Thesis Theme http://bit.ly/KxI4P #thesiswp #-WordPress
Show your latest Tweet on top of Content Column in Thesis Theme http://bit.ly/HL6ng
[...] Read the rest of the story… [...]
Great #thesis tutorial for adding twitter: http://bit.ly/TkGoz
[twitter] Show your latest Tweet on top of Content Column in Thesis Theme http://bit.ly/5vfS5N
[...] 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. [...]
Show your latest Tweet on top of Content Column in #thesiswp Theme – http://bit.ly/dnsaRF #wordpress