0

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?

1

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; ?>
| 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? – Meigo62 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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