WordPress.org

Ready to get started?Download WordPress

Forums

get_sidebar (8 posts)

  1. slavix
    Member
    Posted 4 years ago #

    Hello,
    I am having trouble getting my sidebars working properly..
    My templates says

    <?php get_sidebar('left'); ?>
    ..
    <?php get_sidebar('right'); ?>

    and that loads sidebar-left.php and sidebar-right.php that I have defined.
    My functions.php has

    if ( function_exists('register_sidebar') )
    	register_sidebar(array(
    		'name' => 'left',
    		'before_widget' => '<li>',
    		'after_widget' => '</li>',
    		'before_title' => '<h4>',
    		'after_title' => '</h4>',
    	));
    	register_sidebar(array(
    		'name' => 'right',
    		'before_widget' => '<li>',
    		'after_widget' => '</li>',
    		'before_title' => '<h4>',
    		'after_title' => '</h4>',
    	));

    And I see these sidebars named 'left and 'right' show up in widgets menu. I tried adding widgets to the sidebars, but they don't show up on my sidebars.. where is the problem?

    thanks,
    Slava

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    What are your sidebar files called? They should be sidebar-left.php and sidebar-right.php.

  3. slavix
    Member
    Posted 4 years ago #

    As I mentioned in the original post the sidebar files are named sidebar-left.php and sidebar-right.php

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    Sorry - missed that.

    There's a missing closing } in your functions.php code. Is that just a copy'n'paste error?

    What's in your sidebar files?

  5. miocene22
    Member
    Posted 4 years ago #

    Try removing the final trailing commas for each of the sidebar arrays in functions.php. The last item in the array should not have a comma

  6. slavix
    Member
    Posted 4 years ago #

    ok. made the changes, but it still does not work..
    functions.php:

    <?php
    if ( function_exists('register_sidebar') ) {
    	register_sidebar(array(
    		'name' => 'left',
    		'before_widget' => '<li>',
    		'after_widget' => '</li>',
    		'before_title' => '<h4>',
    		'after_title' => '</h4>'
    	));
    	register_sidebar(array(
    		'name' => 'right',
    		'before_widget' => '<li>',
    		'after_widget' => '</li>',
    		'before_title' => '<h4>',
    		'after_title' => '</h4>'
    	));
    }
    ?>

    sidebar-left.php:

    <div id="right_sidebar" class="tRightSidebar">
        <p>
            <img src="<?php echo bloginfo('template_url'); ?>/images/template/tSpacerRightColumn.gif" width="210" height="40" />
        </p>
        <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('right_sidebar') ) : else : ?>
    
                        <?php wp_list_bookmarks('category_before=<div id="tRightColumnInset1">&category_after=</div>&title_before=<h4>&title_after=</h4>&categorize=1&category=2,7,6&orderby=id&category_orderby=id&show_description=0'); ?>
        <?php endif; ?>
    </div>

    sidebar-left.php:

    <div id="left_sidebar" class="tLeftSidebar">
    
    </div>
  7. esmi
    Forum Moderator
    Posted 4 years ago #

    Try:

    sidebar-left.php:

    <div id="right_sidebar" class="tRightSidebar">
        <p>
            <img src="<?php echo bloginfo('template_url'); ?>/images/template/tSpacerRightColumn.gif" width="210" height="40" />
        </p>
        <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('right') ) : else : ?>
    
                        <?php wp_list_bookmarks('category_before=<div id="tRightColumnInset1">&category_after=</div>&title_before=<h4>&title_after=</h4>&categorize=1&category=2,7,6&orderby=id&category_orderby=id&show_description=0'); ?>
        <?php endif; ?>
    </div>

    sidebar-left.php:

    <div id="left_sidebar" class="tLeftSidebar">
    <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('left')) : ?>
    <?php endif;?>
    </div>
  8. slavix
    Member
    Posted 4 years ago #

    thanks! that worked.

Topic Closed

This topic has been closed to new replies.

About this Topic