• Hi, I have try this lots and can’t seam to get it working… I have created 2 side bars, sidebar.php & sidebar-custom.php which I am trying to widgetize.
    Sidebar 2 appears in my dashboard but nothing appears when I add a widget.
    The code in my function.php is;

    <?php
    if ( function_exists('register_sidebar') )
        register_sidebar();
    ?>
    <?php if ( function_exists ('register_sidebar')) {
        register_sidebar ('sidebar-custom');
    } ?>

    and the code in my sidebar-custom.php is;

    <ul class=”sidebar”>
    	<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar-custom') ) : ?>
    <?php endif; ?>

    Please can someone help, Thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • <?php get_sidebar('custom'); ?>

    You are registering it, you are having a page that gets called… but your not calling it.

    Unless you just forgot to add that part.

    Thread Starter adelphadesign

    (@adelphadesign)

    Sorry forgot to mention the inclusion of <?php get_sidebar('custom'); ?>

    Your ‘register_sidebar(‘sidebar-custom’)’ should probably just be register_sidebar(‘custom’)

    I’m haivng a similar issue…

    Frumph, my sidebar pages are named like adelpha’s. I have some pages with like names (gallery, etc.) so I named the sidebar pages “sidebar-gallery” just to differentiate.

    My issue is, the various sidebars are showing up in the widget page and I’m populating them with different widgets, but no matter what I put in, they all have the same widgets.

    function.php:

    if ( function_exists('register_sidebar') ) {
    	register_sidebar(array('name'=>'sidebar_default',
    		'before_widget' => '<li>',
    		'after_widget' => '</li>',
    		'before_title' => '<h2>',
    		'after_title' => '</h2>',
    	));
    	register_sidebar(array('name'=>'sidebar_gallery',
    		'before_widget' => '<li>',
    		'after_widget' => '</li>',
    		'before_title' => '<h2>',
    		'after_title' => '</h2>',
    	));
    	register_sidebar(array('name'=>'sidebar_about',
    		'before_widget' => '<li>',
    		'after_widget' => '</li>',
    		'before_title' => '<h2>',
    		'after_title' => '</h2>',
    	));
    }

    sidebar_default:

    <?php 	/* Widgetized sidebar, if you have the plugin installed. */
    					if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar_default') ) : ?>

    page.php:

    <?php get_sidebar('sidebar_default'); ?>

    sidebar_gallery & gallery.php have the same code with the names replaced accordingly (gallery.php being a custom template page).

    No matter what widgets I add in to those sidebars, every one of them is a copy of sidebar_default.php.

    What am I doing wrong here?!
    Thanks in advance!

    ^ get_sidebar is where your problem is

    when you put get_sidebar(‘name’) it checks your php files for sidebar-name.php The only reference for that name => in your register sidebar should be a part of the dynamic_sidebar(‘sidebar_about’) part

    for example.

    In your theme you put get_sidebar(‘inblog’); it will then go and look for the file sidebar-inblog.php if it doesnt find it, it will revert to sidebar.php

    Inside your sidebar.php file or sidebar-inblog you have the dynamic-sidebar(‘sidebar_inblog’) that you registered.

    get_sidebar does *not* use the reference of the sidebar registered it uses the reference of which file to load.

    Thanks, I think see what you’re saying. In function.php and the associated sidebar file (sidebar_custom.php) I use the full file name (sidebar_custom) but when calling it via the actual page I just use ‘custom’. Am I reading that correctly?

    Does the separator matter? I mean, using sidebar-custom.php instead of sidebar_custom.php? Do I have a syntax error as well?

    I believe it should be sidebar-custom.php, with the hyphen, not with _ underscore

    also, you name the file sidebar-custom.php, that is the only time you use the full name sidebar-custom

    in functions.php it’s just ‘name’=>’custom’,
    when called in a template it’s just <?php get_sidebar ('custom'); ?>

    I hope someone can help me as I’ve been stuck on this for 2 days…

    I want a sidebar on the left, my content in the middle and another sidebar on the right (3 column layout). No matter what I do my theme doesn’t recognise my custom sidebar files and only ever display the code from sidebar.php. If I remove sidebar.php from my custom theme then it reverts to using the sidebar.php file in the default theme folder.

    Below is a list of my files and code used in them:

    I have one file called sidebar-left.php and another called sidebar-right.php

    In my theme’s index.php file I have the following code:

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

    in my functions.php file I have this code:

    if ( function_exists('register_sidebar') ) {
    
    	register_sidebar(array('name'=>'sidebar-left',
    		'before_widget' => '<li>',
    		'after_widget' => '</li>',
    		'before_title' => '<h2>',
    		'after_title' => '</h2>',
    	));
    
    	register_sidebar(array('name'=>'sidebar-right',
    		'before_widget' => '<li>',
    		'after_widget' => '</li>',
    		'before_title' => '<h2>',
    		'after_title' => '</h2>',
    	));
    }

    Both of my sidebars are showing in my WP Admin Panel and I can add widgets to them, but neither of them will display in on my page.

    Really hoping someone can provide assistance with this. Thanks in advance.

    get_sidebar(‘$left’);

    will try to find the file sidebar-$left.php

    get rid of the $ first, fix the name of the file.

    i.e. get_sidebar(‘left’); so the file it looks for is sidebar-left.php

    <?php dynamic-sidebar(‘sidebar-right’); ?>

    will display that sidebar where you want it to in your page

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Custom sidebar’ is closed to new replies.