Hey everyone.
I'd made a thread on this earlier, but the question of the thread was answered, so I'm making a new one.
What my issue has been, has been every time I add a widget to the sidebar, I lose the CSS formatting on the sidebar.
The sidebar.php file has a few of the widgets hard coded into it, with the 'BlockContent' class applied to them, that adds a background and border to the widget, but whenever I go into the admin section of the blog and add a widget on the sidebar (even adding just the ones that are there already, coded into sidebar.php) the formatting disappears and looking at the code, the "BlockContent" divs are replaced with calendar-3 pages-3, categories-3, archives-3, and linkcat-2.
What people said was to use register_sidebar, but I'm not sure where to put the code, and what to change the code to, to make it so any widgets have the 'BlockContent' CSS rule.
I'm also wondering how I add a second sidebar to the site, on the right, and have two sidebars show up under the admin 'widget' section.
Thanks so much, Any help would be great!
For troubleshooting, here's my current code:
sidebar.php:
<div class="Left">
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar() ) : else : ?>
<br />
<div class="BlockContent">
<h2><?php _e('Calendar'); ?></h2>
<?php get_calendar(); ?>
</div>
<br />
<div class="BlockContent">
<?php wp_list_pages('depth=3&title_li=<h2>Pages</h2>'); ?>
</div>
<br />
<div class="BlockContent">
<h2><?php _e('Categories'); ?></h2>
<?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>
</div>
<br />
<div class="BlockContent">
<h2><?php _e('Archives'); ?></h2>
<?php wp_get_archives('type=monthly'); ?>
</div>
<br />
<div class="BlockContent">
<?php get_links_list(); ?>
</div>
<br />
<div class="BlockContent">
<h2><?php _e('Meta'); ?></h2>
<?php wp_register(); ?>
<?php wp_loginout(); ?>
<?php wp_meta(); ?>
</div>
<?php endif; ?>
</div>
functions.php:
<?php
$args = array(
'name' => sprintf(__('Sidebar %d'), $i ),
'id' => 'sidebar-$i',
'description' => '',
'before_widget' => '<li id="%1$s" class="BlockContent %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>' );
if ( function_exists('register_sidebar') ) register_sidebar($args);
?>
index.php:
<?php get_header(); ?>
<?php get_sidebar(); ?>
<div id="Content">
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<div class="post">
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<div class="entry">
<?php the_content(); ?>
<p class="postmetadata">
<?php _e('Filed under:'); ?> <?php the_category(', ') ?> <?php _e('by'); ?> <?php the_author(); ?><br />
<?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', ' | ', ''); ?>
</p>
</div>
</div>
<?php endwhile; ?>
<div class="navigation">
<?php posts_nav_link(); ?>
</div>
<?php else : ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php_e('Not Found'); ?></h2>
</div>
<?php endif; ?>
</div>
<?php get_footer(); ?>
</div>
</body>
</html>