Support » Themes and Templates » Widget showing in admin, not on page

  • Resolved roymiller

    (@roymiller)


    Hi there,

    I am brand new to WordPress, but I’m trying to create my own theme. How’s that for opening a can of worms?

    Based on my online research, this exercise doesn’t seem tremendously difficult. I’m an old software developer (no PHP experience), so most of the concepts are familiar to me.

    My WP install is brand new, version 2.9.2, very few plugins installed and only one activated (my WishList Member membership plugin).

    I’m nearly done with the core of my theme. The last step is to widgetize a couple spots, including one that’s not in a sidebar. I’ve modified index.php and functions.php to do that.

    Here’s my funcions.php file (I hope the code tags work):


    <?php
    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    'name' => 'Message',
    'description' => 'This is a sample widget.',
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '',
    'after_title' => '',
    ));
    ?>

    Kept it simple to test this out. As far as I can tell, there’s nothing invalid about that code. WP throws no errors. Notice that I named my sample widgetized area “Message”.

    Here’s what I put in my index.php file:


    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Message') ) : ?>
    <p>Not registered</p>
    <?php endif; ?>

    The Widgets page shows my Message widget area just fine, and I can drag a Text widget over there and configure it. It seems to save without a hitch. But my page shows the “Not registered” message, which suggests that the widget never got registered properly somehow. When I put in some debugging statements, I can confirm that the dynamic_sidebar function exists, but this returns true:


    !dynamic_sidebar('Message')

    I did a similar experiment with the same code in the default theme, and got the same results…widget appears in admin, but not on the page. So I don’t think it’s my custom theme that’s causing a problem. It seems to be a problem with any theme.

    Can anybody tell me what I’m doing wrong? Is there some kind of “don’t display widgets even if they’re there” setting that I’m missing?

    Thanks for your help.

    Roy

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter roymiller

    (@roymiller)

    Yep, did that. That’s where I got the code.

    Apparently, the problem was a cache issue of some sort. Refreshing the browser wouldn’t fix it, but when I exited WP and logged back in, everything functioned as expected. With the code I listed.

    Odd, but when it doubt, reboot.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Widget showing in admin, not on page’ is closed to new replies.