0

My intention is to have a left and right sidebar on each page. I've registered both of them, implemented my desired widgets, and yet something isn't quite right.

The left sidebar (sidebar(1)) loads correctly on the left side, but is stuck beneath page content. The right sidebar (sidebar(2)) does not show up on the page at all though it does appear to be active in Appearance > Widgets.

What have I overlooked? What can be done to allow for the two sidebars to show and function properly? Thanks.

Here's what I have:

single.php

<?php get_header(); ?>

<div id="content">

    <div id="blog">

        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <h1 class="title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>

        <p class="date">Posted on <?php the_time('F j, Y'); ?> | <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p>


        <div class="post">
            <?php the_content(__('Read more'));?><div style="clear:both;"></div>

            <div class="bt-links"><strong>Category:</strong> <?php the_category(', ') ?><br /><?php the_tags('<strong>Tags:</strong> ',' > '); ?></div>
        </div><!-- end post -->

        <!--
        <?php trackback_rdf(); ?>
        -->

        <?php endwhile; else: ?>

        <p><?php _e('Nothing found here, uh oh!'); ?></p><?php endif; ?>

    </div><!-- end blog -->

</div>

<!-- The main column ends  -->

<?php get_sidebar('l'); ?>
<?php get_sidebar('r'); ?>
<?php get_footer(); ?>

sidebar-l.php

<div id="sidebar-left">
    <ul class="l_sidebarwidgeted">
        <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) : else : ?>
    </ul>
</div><!-- end sidebar-left -->

sidebar-r.php

<div id="sidebar-right">
    <ul class="l_sidebarwidgeted">
        <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : ?>
    </ul>
</div><!-- end sidebar-right -->

functions.php

<?php
if ( function_exists('register_sidebars') )
    register_sidebars(2);
?>

css

#sidebar {
    width: 200px;
}

#sidebar-left {
    float: left;
}

#sidebar-right {
    float: right;
}

p.sidebar {
    font-size: 80%;
}
2

you are using the wrong file names for the sidebar templates; try the file names sidebar-l.php and sidebar-r.php

review http://codex.wordpress.org/Function_Reference/get_sidebar

  • This makes sense, however even after changing the template names the sidebars still do not show up. In fact, the left sidebar which previously showed at the bottom of the page is no longer there. – user1255049 Oct 7 '13 at 14:29
  • 1
    in that case, you might have further errors in the coding and formatting of the sidebars which is impossible to check without a live link to your site. for instance, the èndif` of your conditional statements is missing. please enable DEBUG codex.wordpress.org/Debugging_in_WordPress and report any errors. – Michael Oct 7 '13 at 14:48
  • Debugging returned these errors: Notice: Use of undefined constant l - assumed 'l' in path/single.php on line 33 Parse error: syntax error, unexpected end of file in path/sidebar-l.php on line 5 --- The files in question are listed in my original post. – user1255049 Oct 7 '13 at 23:02
  • "undefined constant l " was repaired by changing '<?php get_sidebar(l); ?>' to '<?php get_sidebar('l'); ?>', the only error remaining now is Parse error: syntax error, unexpected end of file in path/sidebar-l.php on line 5 – user1255049 Oct 7 '13 at 23:18
1

Mostly the problem occurs when you wrongly register sidebar in function.php or you register your sider with the name which do not match with name you use to output your sidebar.

Can you add the code here which you use to register your sidebar in function.php? so i can look what exactly is the problem.

You can find here that How To Create Multiple Widget Area In WordPress Theme.

  • Just added the bit from functions.php. Thanks for taking a look at it. – user1255049 Oct 6 '13 at 23:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.