Reputation: 1476
I already posted this on wordpress support, but the answers here are much faster...
This is a 'copy-paste' from there:
I want extra widget area on my home.php template. I'm using Responsive theme by Emil Uzelac. I have no idea why my extra 'sidebar' is not working.
dynamic_sidebar('front-side-sidebar');
The function returns true but it displays nothing. I can see my extra widget area in "Widgets" and I did add one widget there. In my functions.php I have this:
function front_side_sidebar_init()
{
register_sidebar(
array(
'id' => 'front-side-sidebar',
'name'=>'Front Side sidebar',
'description' => __('Front Side sidebar', 'responsive'),
'before_widget' => '<li>',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>'
)
);
}
add_action( 'widgets_init', 'front_side_sidebar_init' );
Upvotes: 3
Views: 8609
Reputation: 195
This is how I would do it, I dont know if the theme have made a function for creating new sidebars in theme options, so thats why i answer as i do.
In Functions.php add this
register_sidebar(array(
'name' => __( 'Front Side sidebar' ),
'id' => 'front-side-sidebar',
'description' => __( '' ),
'before_widget' => '<div class="widget">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>'
));
If you have set a static front page, then wordpress will use front-page.php. If you dont have this it will use page.php, I am bad at english but check more here. HERE!
In your template (front-page.php or page.php home.php what you are useing) Replace your sidebar area () with this
<?php get_sidebar('front-page'); ?>
This code will look for the file, sidebar-front-page.php and in that file you will add this code. Add sidebar-front-page.php in template directory
<?php if(!function_exists('dynamic_sidebar') || !dynamic_sidebar('front-side-sidebar')) : ?>(you can also put code here if you dont have anything in the this sidebar, it will show this function as standard if you dont have any thing on this sidebar.<?php endif; ?>
Long story short, this code will check for the sidebar with id 'front-side-sidebar' and show the widgets you have set in the sidebar.
Yeah, well this should work! :)
Upvotes: 6
Reputation: 3593
Have you solved the issue here? this may sound very silly but makesure the code is surrounded by your PHP tags <?php ?>
Upvotes: -5