Reputation: 2562
I have added some widgets to my homepage sidebar, but they are not appearing on the home page. If I add some widgets to the main sidebar it will appear in home page, and other pages.
I am new to Wordpress, I don't know how to solve this issue, and also default widgets are not appearing. I am using wp-bootstrap
theme and a Q/A paid plugin.
Upvotes: 1
Views: 2788
Reputation: 1049
First of all register your homepage sidebar in function.php
function Name_widgets_init() {
register_sidebar(array(
'name' => __( 'homepage sidebar', 'test theme' ),
'id' => 'sidebar_homepage',
'description' => __( 'This Wwill appear on homepage sidebar', 'test theme' )
) );
}
add_action( 'widgets_init', 'Name_widgets_init' );
Than use this trick to display your widgets, put the following code to the home page where you want to add sidebar
<div class="sidebar_home" id="sidebar_left">
<?php if ( is_active_sidebar( 'sidebar-left' ) ) : ?>
<div id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar_homepage' ); ?>
</div>
<?php endif; ?>
</div>
Finally Note i have used a div in last chunk of code please write your own CSS to control it.
Upvotes: 1