WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Widget showing in admin, not on page (3 posts)

  1. roymiller
    Member
    Posted 4 years ago #

    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

  2. esmi
    Forum Moderator
    Posted 4 years ago #

  3. roymiller
    Member
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic