• Hello there!

    I have two questions that I’m hoping to receive some help with. I am running the latest version of WordPress, and the Pandora theme.

    First, I’m just trying to figure out how to apply my theme’s CSS styling to a custom sidebar that I’m using on most pages on my site. You can see the sidebar looks great here:

    http://coreychandler.net/wordpress/?page_id=62

    …but when I use the custom one, it looks horrible:

    http://coreychandler.net/wordpress/?page_id=39

    Do you know how I can ensure that my theme’s CSS styling is being applied to my custom sidebar? Here is how I’m invoking it:

    In page.php:

    <?php if ( !function_exists('dynamic_sidebar')
    || !dynamic_sidebar('Sidebar2') ) : ?>
    <?php endif; ?>

    In fuctions.php:

    if(function_exists('register_sidebar')) {
    
    		register_sidebar(array(
    		'name' => __('Sidebar'),
    
    		'before_widget' => '<li id="%1$s" class="widget %2$s">',
            'after_widget' => '</li>',
            'before_title' => '<h3>',
            'after_title' => '</h3>',
    
    	));
    
    		register_sidebar(array(
    		'name' => __('Sidebar2'),
    
    		'before_widget' => '<li id="%1$s" class="widget %2$s">',
            'after_widget' => '</li>',
            'before_title' => '<h3>',
            'after_title' => '</h3>',
    
    	));

    Any thoughts?

    My second question is this: I’ve managed to do a workaround so get my Blog page to show the sidebar I want, but in reality what I’d really like to do is point it to a template that will invoke the appropriate sidebar. For some reason, however, the blog page seems to insist in invoking the site’s default “Sidebar,” even though the template is telling it not too. Do you know why this is?

    Thanks so much in advance, and please let me know if I need to provide any more clarification.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You need to create a sidebar-2.php file for this custom sidebar that places the sidebar content inside </div class="sidebar"></div> block.

    what I’d really like to do is point it to a template that will invoke the appropriate sidebar

    And when should it use this second sidebar?

    Thread Starter yeroc

    (@yeroc)

    Thank you so much for your help!

    I created the sidebar-2.php file, but still to no avail. To make it, I just copied the sidebar.php file – is that right? Or do I need to modify anything about the file?

    Or is the issue that I’m not invoking this new file somewhere?

    You do need to invoke it using <?php get_sidebar('2');?> but you still haven’t defined when you want to to be used.

    Thread Starter yeroc

    (@yeroc)

    Aha! I figured it out. Here’s what I did:

    As esmi suggested, create a sidebar-2.php file.

    Within that file, change this:

    <?php /* WordPress Widget Support */ if (function_exists('dynamic_sidebar') and dynamic_sidebar(1)) { } else { ?>

    to this:

    <?php /* WordPress Widget Support */ if (function_exists('dynamic_sidebar') and dynamic_sidebar(2)) { } else { ?>

    …so that it will be associated with the 2nd sidebar in the array I defined in functions.php.

    Then, I went into my page.php template and nixed this code:

    <?php if ( !function_exists('dynamic_sidebar')
    || !dynamic_sidebar('Sidebar2') ) : ?>
    <?php endif; ?>

    …and instead used this:

    <?php include ('sidebar-2.php'); ?>

    …et voila! All appears well in the world.

    I’m a little confused why so many sites were saying for me to use that funky if statement, though. Am I going about this the wrong way?

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Custom Blog Page Sidebars & CSS’ is closed to new replies.