Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I tried to add a custom page to my Wordpress template. That part is good. What I´m stuck with is a common sidebar that appears although I registered a custom sidebar for it.

I am calling the sidebar...

<?php get_sidebar('dfth'); ?>

And registering sidebar (below there is default sidebars registered also)

function web2feel_widgets_init() {

register_sidebar( array(

    'name' => __( 'Sidebar', 'web2feel' ),

    'id' => 'sidebar-1',

    'before_widget' => '<aside id="%1$s" class="widget %2$s">',

    'after_widget' => '</aside>',

    'before_title' => '<h1 class="widget-title">',

    'after_title' => '</h1>',

) );

    register_sidebar(array(

    'name' => 'Footer',

    'before_widget' => '<li class="botwid grid_2 %2$s">',

    'after_widget' => '</li>',

    'before_title' => '<h3 class="bothead">',

    'after_title' => '</h3>',

));     

        register_sidebar( array(

    'name' => __( 'Throwers ),

    'id' => 'dfth',

    'before_widget' => '<aside id="%1$s" class="widget %2$s">',

    'after_widget' => '</aside>',

    'before_title' => '<h1 class="widget-title">',

    'after_title' => '</h1>',

) );



}

    add_action( 'widgets_init', 'web2feel_widgets_init' );

I just don´t get what´s happening, everything seems to be okay but sidebar still doesn´t come up. I get an error: Parse error: syntax error, unexpected T_REQUIRE_ONCE in /data01/virt30509/domeenid/www.throwholics.com/htdocs/wp-content/themes/Underfire/functions.php on line 1Any ideas?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

get_sidebar('dfth') looks for a sidebar-dfth.php file in your template directory. If not found, it loads the default sidebar. To call the sidebar you registered in a template, use e.g.

<?php if ( is_active_sidebar( 'dfth' ) ) : ?>
<div class="first dfth-widgets">
    <?php dynamic_sidebar( 'dfth' ); ?>
</div><!-- .first -->
<?php endif; ?>
share|improve this answer
    
<?php if ( is_active_sidebar( 'dfth' ) ) : ?> <div class="first dfth-widgets"> <?php dynamic_sidebar( 'dfth' ); ?> </div><!-- .first --> <?php endif; ?> Thats the sidebar template right? –  Meigo Al Dozary Jan 14 '13 at 12:17
    
dynamic_sidebar() calls each of the active widget callbacks in order, which prints the markup for the sidebar (codex.wordpress.org/Function_Reference/dynamic_sidebar). –  diggy Jan 14 '13 at 12:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.