WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] widgetizing areas (3 posts)

  1. bluedrag
    Member
    Posted 2 years ago #

    Hello WordPress,

    I'm trying to add a widget area to my theme.. It doesn't seem to be working though.. I've done this before so I'm sure it's just something small and stupid thats stopping it from working this time.. Maybe someone here can help me.

    Here is the code in my html file

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

    Here is the code in my functions.php

    <?php
    
    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    'name' => 'searchbar',
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '',
    'after_title' => '',
    ));
    
    ?>
  2. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

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

    You are excluding with the !. That says if there is no dynamic sidebar, so WP would then be looking for code to display if the sidebar doesn't exist.

    THe markup I use in my html looks like:

    <?php if ( is_active_sidebar( 'searchbar' ) ) : ?>
    	<div class="post post-widget-area hentry">
    		<ul class="xoxo">
    			<?php dynamic_sidebar( 'searchbar' ); ?>
    		</ul>
    	</div><!-- #first .widget-area -->
    <?php endif; ?>

    http://vudu.me/k
    for a little writeup

  3. bluedrag
    Member
    Posted 2 years ago #

    Hey, thanks for your help, I wrote it out a little bit differently, but you were right about what I was doing wrong thank you. This is what I used (in the html file)

    <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('searchbar')) : else : ?>
    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic