When you have more than 100 themes, it is expected that some users will want to port features between themes. One of the most requested is the Twitter feed that you can see in the header of the Busybee theme. In this tutorial you’ll learn how to add a Twitter feed to the Canvas header using hooks.
The final result
The finished code
add_action('woo_header_inside','woo_add_twitter_header', 10);
function woo_add_twitter_header() {
?>
<div id="twitter_header">
<ul id="twitter_update_list_header"><li></li></ul>
<?php echo woo_twitter_script('header', 'woothemes', 1); ?>
<div class="fix"></div>
</div>
<?php
} // End woo_add_twitter_header()
What the code does
- Instruct the “woo_header_inside” hook to look for and execute the “woo_add_twitter_header()” function.
- Setup a wrapping DIV tag with an ID of “twitter_header” and the necessary markup for the Twitter script. The PHP code outputs the Twitter feed for the username woothemes (replace with yours).
Lastly, the CSS and the Twitter bird image
If you test the code right now, you should see the Twitter feed in your header above your logo. We don’t want it there so we must add some CSS to the “custom.css” file.
#twitter_header { float: right; padding-left:60px; background:url(images/twitter_bird.png) no-repeat left center; }
#twitter_header a.time { display:block; }
The CSS above adds the Twitter bird image as background to the left of your “twitter_header” DIV and also some padding or the image would be under your text. The last line moves the time to a new line.
You can grab the Twitter bird HERE. Add it to your theme “images” folder or, alternatively, replace “images/twitter_bird.png” with the full url to the image (example: http://your-site.com/twitter_bird.png).
A teljes bejegyzés elolvasása















