Support » Fixing WordPress » Adding widget areas

  • I’m trying to add a widget area to my theme, but it doesn’t seem to be working. I’ve added widget areas to wordpress themes many many times before and I’ve never had a problem with them… I have no idea why it’s not working this time, here is the code I’m using..

    functions.php

    <?php
    if (function_exists('register_sidebar')) {
    
    	register_sidebar(array(
    		'name' => 'navbar',
    		'description'   => '',
    		'before_widget' => '',
    		'after_widget'  => '',
    		'before_title'  => '',
    		'after_title'   => ''
    	));
    
    ?>

    header.php

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

    side note: I dont get a php error or anything, nothing happens.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You’re missing your closing curly brace in the function:

    <?php
    if (function_exists('register_sidebar')) {
    
    	register_sidebar(array(
    		'name' => 'navbar',
    		'description'   => '',
    		'before_widget' => '',
    		'after_widget'  => '',
    		'before_title'  => '',
    		'after_title'   => ''
    	));
    
    ?>
    Thread Starter bluedrag

    (@bluedrag)

    Hmm.. it still doesn’t seem to be working. Is this what you meant?

    <?php
    if (function_exists('register_sidebar')) {
    
    	register_sidebar(array(
    		'name' => 'navbar',
    		'description'   => '',
    		'before_widget' => '',
    		'after_widget'  => '',
    		'before_title'  => '',
    		'after_title'   => ''
    	));
    }
    
    ?>

    Why don’t you paste the entire contents of functions.php into a Pastebin.

    Actually, never mind – I think it’s something else. Do you have a line in header.php actually calling in the widget?

    <?php dynamic_sidebar( 'navbar' ); ?>

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding widget areas’ is closed to new replies.