HowTo make the Sidebar visible on each page of the WordPress default template

The default Template of WordPress don’t show the Sidebar on each page. One of the pages without sidebar is the comment page. I don’t like this behavior because a page without main navigation is a bit deceptive. To change this, we only need to change a few lines of code:

  1. in single.php
    change the style of the div from widecolumn to narrowcolumn :

    <div id="content" class="narrowcolumn">

    at the end of the file add

    <?php get_sidebar(); ?>

    before

    <?php get_footer(); ?>
  2. in header.php
    to give the sidebar the light gray background, we need to remove the if in the middle of the file. Change

    <?php
    // Checks to see whether it needs a sidebar or not
    if ( !$withcomments && !is_single() ) {
    ?>
    #page { background: url("<?php bloginfo(...repeat-y top;
     	border: none; }
    <?php } else { // No sidebar ?>
    #page { background: url("<?php bloginfo(...repeat-y top;
    	 border: none; }
    <?php } ?>

    to:

    #page { background: url("
    <?php bloginfo('stylesheet_directory'); ?>
    /images/kubrickbgwide.jpg") repeat-y top; border: none; }

If you want to add a Home Link into the comments page, extend the link area in single.php:

<div class="navigation">
 <div class="alignleft"><?php previous_post_link('« %link') ?></div>
 <div><a href="<?php echo get_option('home'); ?>/">Home</a></div>
 <div class="alignright"><?php next_post_link('%link »') ?></div>
</div>

1 thought on “HowTo make the Sidebar visible on each page of the WordPress default template

  1. Pingback: Gen Drebery

Leave a Reply

Your email address will not be published. Required fields are marked *