• Resolved bluedrag

    (@bluedrag)


    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' => '',
    ));
    
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • <?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; ?>

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

    Thread Starter bluedrag

    (@bluedrag)

    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; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘widgetizing areas’ is closed to new replies.