Wordpress Tutorial: Adding Tabs to Your Blog Sidebar

What’s the best script?

The recent blog redesign gave me a bit of a head ache. In order to implement the tabbed navigation from my sidebar, I had to test a couple of scripts. I know all of them integrate like a charm on other Wordpress blogs, but for one reason or another, each time I finished setting up and customizing a certain script, some new weird bug showed up.

The problems were caused by various factors (some of them very weird): having other anchor links (like #comments) in my Wordpress theme, a conflict between Prototype framework used by Wordpress and jQuery used by a script, etc, etc.

So after testing DomTab, Tabifier and idTabs, I finally managed to get the job done. When all hope was lost, I thought I should give Yahoo! UI Library a shot. They have this really neat component called TabView, which in my case worked like clockwork. On top of that, it’s pretty quick and has absolutely no flicker or delay when loading the content. All the other scripts had at least a small delay.

I saw implementations of each of the above mentioned scripts on Wordpress and they all have pretty much the same HTML structure. Still, I think the Yahoo! TabView is the best choice.

Implementing Yahoo! TabView

In this Wordpress tutorial I won’t go into too many details about the script or HTML, since you can get all that info from the TabView homepage. Instead, I will focus on the specifics of using this script with Wordpress, as well as pointing out what CSS code you need to add to your style.css file, for a seamless integration with your Wordpress theme.

First of all, you need to know that you won’t be able to insert widgets into the tabbed navigation, using the visual editor from Wordpress admin. You can still add widgets, but outside the tabbed navigation.

I personally stopped using widgets in themes that I design for myself. So if you are ready to “get your hands dirty” and really customize your own theme, I think this is the best way to go.

So just add the script reference to your header.php and the HTML code to the sidebar.php file. Now you’re ready to perform some CSS surgery. ;) We’ll use the script’s built-in styles.

The CSS explained

Styling for the tabbed panel that holds everything together (yui-navset):

.yui-navset {
	background: #E8F4FD;
	padding: 5px 5px 3px 5px;
	margin-bottom: 35px;
}

Styling for the actual tabs (yui-nav):

.yui-nav li
{
	list-style: none;
	float: left;
	margin-right: 2px;
	text-align: center;
	font-size: 90%;
	font-weight: bold;
}

.yui-nav li a
{
	text-decoration:none;
	color: #005288;
	display: block;
	padding: 8px;
}

.yui-nav li.selected a {
	background: #FFFFFF;
}

.yui-nav li a:hover
{
	color: #000;
}

Styling for the content holder (yui-content):

.yui-content {
	background: #FFFFFF;
	clear: both;
}

Of course you will also have to style the content itself, like unordered lists, paragraphs, etc. For example, my content is made of unordered lists, which have the following style assigned to them:

.tab-list li {
	padding: 8px;
	border-bottom: 2px solid #E8F4FD;
}

This adds that nice white space around the list items, as well as a 2px bottom border. That’s about it! When it comes to CSS, the possibilities are endless, so feel free to experiment. Hope this tutorial helps you make the best choice when it comes to Wordpress sidebar tabs.

For a great roundup of tab-based scripts, you might want to check this link: 37+ Great Ajax, CSS Tab-Based Interfaces.

Similar Posts (Maybe)

7 Trackbacks

  1. [...] Beth’s BORROWED pick: Sidebar Tabs [...]

  2. [...] Beth’s BORROWED Pick: Sidebar Tabs [...]

  3. [...] Beth’s BORROWED pick: Sidebar Tabs [...]

  4. [...] Wordpress Tutorial: Adding tabs to your blog sidebar | Custom Wordpress Theme Designer [...]

  5. [...] Adding Tabs to Your WordPress Blog: Adrian Diaconescu at Rubiqube went looking for a good tabbed-content solution for his WordPress sidebar, but he couldn’t find something that fully scratched the itch. His response was to deploy the YUI TabView Control, and he’s written up a detailed tutorial so you can leverage his work. [...]

  6. [...] month I wrote a Wordpress tutorial about adding tabs to a blog sidebar, that was pretty popular, jufging from the number of comments and trackback it’s been [...]

  7. [...] Wordpress Tutorial: Adding Tabs to Your Blog Sidebar by Rubiqube.com [...]

11 Comments

  1. Posted May 25, 2008 at 4:21 am

    Thank you man!

  2. Posted May 25, 2008 at 7:54 am

    Really neat tutorial. Should have sold this on net tuts. Anyway … it’s really amazing to see that yahoo leaped over google in web developement and resources.

  3. Posted May 25, 2008 at 8:37 am

    Yeah, I wasn’t a very big fan of Yahoo. They seem to have lost the search engine race with Google a long time ago. But when it comes to webdev, Yahoo still has some tricks up their sleeve. ;)

  4. Posted May 26, 2008 at 5:02 am

    Indeed they do. Btw why aren’t you resubmiting rubiqube to all css galleries out there, it would bring a load of trafic over here. :P

  5. Posted May 26, 2008 at 5:05 am

    Will do. I’m still tweaking a couple of things here and there.

  6. Posted May 26, 2008 at 11:15 pm

    Good stuff Adrian! :)

    Just one thing though, and I’m not sure at all cause I haven’t tried it, , but you said you won’t be able to insert widgets into the tabbed navigation, but wouldn’t it be possible to “widgetize” it by creating say tab1.php, tab2.php, tab3.php and so on (for as many tabs as you want) and then adding the ” code? just as if they were all ‘little’ sidebars? And change the ‘dynamic_sidebar() ‘ to dynamic_sidebar(2) and dynamic_sidebar(3) , etc…

    And then modify the functions.php to include these new sidebars, and (I guess) they should show up in the Presentation->Widgets menu :)

    and then you can add whatever code you want like popular posts, recent comments and stuff like that..

    I’m not even sure what I wrote actually makes any sense… but I’ll try it tomorrow hehe

    Cheers

  7. Posted May 27, 2008 at 1:43 am

    To be honest, the thought crossed my mind. But since you need to add code anyway in order to add a new set of tabs, I just thought it wasn’t worth the trouble. But that’s just me: it’s either 100% flexible, or forget about it. :)

    On the other hand, if a plugin guru happens to read these lines, I think this would make a great start for a highly customizable tabs plugin, where you can add tabbed panels, edit contents, maybe even look and feel.

  8. Posted June 12, 2008 at 8:11 am

    Everything is great, but I would like to know more about - how to add content into the tabs? Like top comentators, top posts, latest comments and so on…

    Andreaz’s last blog post: Metal Gear Solid 4 - statrtavo!

  9. Posted June 12, 2008 at 10:14 am

    Andreaz, I will try to sum this up in my one of my next posts.

  10. Posted June 12, 2008 at 4:20 pm

    WOW! Thanks

  11. Posted June 14, 2008 at 3:23 am

    Great man, really waiting for that.

    Andreaz’s last blog post: CoD 5 atnaujins WWII žanrą

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*