Additional Sidebars

When building a website using WordPress, you’ll often have a piece of content that doesn’t fit into a post or page; for example, an “Additional Information” box that appears above the sidebars on a specific page.  There are many approaches you could take:

  • Code it directly into the template files, which should only be done if the content won’t need to be changed (example: a footer on a website).
  • Include it as a custom field on a post or page. This is best for content that is page/post-specific, but found on almost every post or page (example: Photographer’s name associated with the post’s header image).
  • Build an additional sidebar. This is best for something that’s repeated often and/or needs to be easily editable.

I’m going to focus on the last approach using additional sidebars.

First you need to create an additional sidebar, then include it somewhere in your site, and finally populate it with content.

Creating an Additional Sidebar

In your functions.php file (or core functionality plugin), include the following code:

That will create a new sidebar titled “Additional Sidebar,” with the appropriate default parameters (which you can change if you like).

Include in Site

Now you can simply drop dynamic_sidebar( 'additional') directly in your theme somewhere.

Populate the sidebar with content

From your wp-admin area, go to Appearance > Widgets. You should see all of your sidebars displayed on the right side, and your choice of widgets on the left. If you just want text in this sidebar, drag the Text widget over to “Additional Sidebar” and fill it with your title and content. Once you save it, your sidebar should be ready to view on your site.

You can customize the look and feel of it using CSS.

For more information on building sidebars, check out Justin Tadlock’s excellent post Sidebars in WordPress.

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk

Reader Interactions

Comments are closed. Continue the conversation with me on Twitter: @billerickson

Comments

  1. Julie Gomoll says

    I'm a major Thesis Theme fan. Glad to find another resource for tips 🙂

    My solution for additional sidebars on specific pages: I use the Widget Logic plugin and conditional tags. After installation, you drag a widget to the sidebar. An extra Widget Logic field will appear. To add a widget to a single page, you simply enter

    is_page('pagename')

    And to make it appear on multiple pages, enter

    is_page(array('firstpage','secondpage','thirdpage'))

  2. Rich says

    You have saved my blog! I have been scrounging sooo many tutorials on how to put only 1 category of posts on a given page. Your code and instructions worked. Took me a time or two to get the details right but it was dead on and works perfectly. Now I just have to decided how I want the formatting to look and it'll be done (oh, yeah…and write some more posts for other categories!).

  3. Vincent says

    Hey, I wanted to also share with you that I used the Thesis Openhook plugin to implement Bill tip.
    I highly recommend it.

    You simply need to past the content of "function custom_cat_page()" in the thesis_hook_after_post field.

  4. Brandon Sean says

    Hi thanks a bunch for this tutorial!!

    I got the new sidebar installed on my thesis blog, but right now the prob is the fonts appear to be smaller than usual in this new sidebar. Is there a way to correct it?

    I am using a 3 column layout and this new sidebar is above the 2 sidebars.

    If possible I want this new sidebar to have the same font as the default thesis sidebars?

    • Kira says

      Hi and thanks for the great code,

      I’m having the same problem with the fonts in the new custom sidebar appearing smaller than in the stock thesis sidebars. When I move the widget back to one of the regular sidebars, the fonts are back to normal.

      I am also using a 3 column layout and this new sidebar is above the 2 sidebars.

      Is there a CSS addition i need to make somewhere? Thanks!

      • Bill Erickson says

        Use Firebug or some other HTML inspector to see what styles are applied to your current sidebar, and duplicate those for this sidebar. I can’t tell you which styles to use because it depends on your site’s CSS.

        • Kira says

          Thanks so much for your quick reply! 🙂

          I changed your tag back to the tag, and removed your class and it rendered my sidebar classes perfectly.

          Thanks again, Kira

          • Kira says

            Sorry for posting again – my tag codes were removed.

            Again, I changed your “div” tag back to the “li” tag, and removed your “h3” class and it rendered my sidebar classes perfectly.

            Kira

  5. Lillan says

    Hi!

    I’m fooling around with Thesis 1.8 and wp 3.0+ and I’m not sure how to implement a specific sidebar only on a specific page. Let me explain:

    I have made a custom template with only one sidebar and it works just fine! I use–> function single_sidebar1_template(){ and some codes. I have also registered a new sidebar (widget) which i only want to be seen on this particular page in this specific sidebar. Are you following me?

    The problem:
    I can implement the single sidebar and the widget but how do i make it (widget) only to appear on that specific page? I have also tried to use an if declaration pointed to the actual page – without result.

    When someone navigate to that page i want to have a new single right sidebar with new contents (wp nav) exclusive for that page. No thesis default sidebars at all.

    Do You have any suggestions? You can email the answer if you want.

    Kindly// Lillan

    • Bill Erickson says

      So you’ve created a custom page template that uses your new sidebar. The sidebar should only show up on the pages that are using the custom page template. Did I miss something?

      If you’re using the custom page template on multiple pages and only want a widget to show up on one page, I’d recommend using the Widget Logic plugin. At the bottom of the widget it adds a logic box, and you can put is_page(‘page-name’) to limit it to just that page.

      • Lillan says

        Hi again, and thanks for the tip =) I installed Widget Logic and it’s ok – however, i wanted to take my page a step further so i made a custom template and began with this:

        global $thesis_design;
        if(is_page(‘artists’)){
        global $post;
        $page_template = get_post_meta($post->ID, ‘_wp_page_template’, true);

        echo “\t\t\n\n”;

        echo “\t\t\n\n”;

        }

        in where “artists” its the actual page. After that i used the modified sidebar codes by Greg Rickaby and your Additional Sidebar. To spice up the Template Page and its subpages ( i wanted all to look alike) I used custom_body_classes and some if-statements.

        function custom_body_class($classes) {
        if(is_page_template (”)) {
        $classes[] = ‘konstnarer’;
        return $classes;
        } else {
        if (is_home() || is_single() || is_page () || is_archive() || is_search() || is_404() || is_category() ) {
        $classes[] = ”;
        return $classes;

        }
        }
        }
        add_filter(‘thesis_body_classes’, ‘custom_body_class’);

        I’m satisfied =)

        Now I wonder if you are able to give me some advice for the Thesis loop? I have wp-queries for a category as a custom_featured_post.

        $custom_loop = new WP_Query(‘showposts=3&category_name=nyheter&orderby=rand’);
        if ( $custom_loop->have_posts() ) :
        while ( $custom_loop->have_posts() ) : $custom_loop->the_post();
        $do_not_duplicate[] = $post->ID; $postcount++;

        This works like charm, but i can’t to prevent the posts from beeing duplicated in the ordinary Loop. In my “default before Thesis” WP-files i used this (within php tags naturally):

        if (have_posts()) : while (have_posts()) : the_post();
        if (in_array($post->ID, $do_not_duplicate)) continue;

        But how do i implement it in Thesis? I have tried for hours now without any results. Can you help me?

        Thanks in advance/Lillan

  6. Lillan says

    A quick question (sorry for spamming you) – what do i have to do for not trigging thesis_body_classes to all other pages when i use the custom template?

    The if-statement:

    if(is_page_template (‘artists.php’)) {
    $classes[] = ‘konstnarer’;
    return $classes;
    } else {
    if (is_home() || is_single() || is_page () || is_archive() || is_search() || is_404() || is_category() ) {
    $classes[] = ”;

    Index-page and single-page works fine, and so the parent page and child pages for which i use the custom template “artists.php” with the body class “konstnarer”.

    But when i do other pages they all gets body class “konstnarer”. It seems right now i have 2 alternatives:

    1) NOT to define is_page_template as “artists.php” = i get my 2 col layout for the specific page and its child pages BUT this triggers the other “pages” to implement the very same body class (konstnarer) as well and their 3 col layout crashes (default sidebar 1 ends up under everything instead to be on the left side).

    2) Define is_page_template to “artists.php” = each page has its own body class and the specific page and its child pages have body class “konstnarer”. But this triggers on the other hand the custom template “artists.php” back to a 3 col layout without sidebar 1 -> an empty area on the left side without a sidebar. It’s ugly.

    I have define the content area in my css :
    .custom .konstnarer #content {float:left;width:74em; background:transparent!important; }

    .konstnarer div#content {float:left;width:74em !important; background:transparent;}

    I have struggled with this in hours – so i wonder; how to define the default body classes to ALL pages except for those with body class “konstnarer” so 1) my 2 col layout works with the custom template “artists.php” and 2) the ordinary 3 col layout on the others?

    Kindly Lillan

  7. Abby says

    Silly question – but the “sidebar” customizations aren’t sticking for the new sidebar. Where would I add those customizations to make them match? Within the code above or elsewhere? Site in progress: http://www.QuaverMusicBlog.com

    Thanks for this – huge help!

    • Bill Erickson says

      Make sure it has the same css classes applied to it (ex: class=”sidebar”).