WordPress.org

Ready to get started?Download WordPress

Forums

Adding widget areas (5 posts)

  1. bluedrag
    Member
    Posted 2 years ago #

    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.

  2. 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'   => ''
    	));
    
    ?>
  3. bluedrag
    Member
    Posted 2 years ago #

    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'   => ''
    	));
    }
    
    ?>
  4. Why don't you paste the entire contents of functions.php into a Pastebin.

  5. 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' ); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic