samdz Posted February 16, 2014 Report Share Posted February 16, 2014 Hello, I am working to build my own theme, I learned a lot with (Build a Wordpress Theme from Scratch) but now I have problem to insert 2 sidebars in functions.php I added: ---------------------------------------------------------------------- function mytheme_widgets_init() { register_sidebar( array( 'name' => __( 'sidebar-1', 'mytheme' ), 'id' => 'sidebar-1', 'description' => __( 'sidebarRight', 'mytheme' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); register_sidebar( array( 'name' => __( 'sidebar-2', 'mytheme' ), 'id' => 'sidebar-2', 'description' => __( 'SidebarLeft', 'mytheme' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); } add_action( 'widgets_init', 'mytheme_widgets_init' ); -------------------------------------------------------------------- I have: sidebar.php and sadebar2.php sidebar 1 is ok, it's diplayed but sidebar-2 no!!... I added this php code (but I am begginer so I don't know if's correct ) --------------------------------------------------------------------- <?php ?> <?php if ( is_active_sidebar( 'sidebar-2' ) ) : ?> <div id="secondary" class="widget-area" role="complementary"> <?php dynamic_sidebar( 'sidebar-2' ); ?> </div><!-- #secondary --> <?php endif; ?> <?php get_sidebar('sidebar-2'); ?> <div id="sidebar-2"> <ul class="nav"> <li><a href="#">Lien un</a></li> <li><a href="#">Lien deux</a></li> <li><a href="#">Lien trois</a></li> <li><a href="#">Lien quatre</a></li> <?php wp_nav_menu( array('menu' => 'Project Nav', 'container' => '' )); ?> </div> <!-- end .sidebar2 --></div> --------------------------------------------------------------------- I added in index.php and front-page.php <?php get_sidebar(); ?> <?php get_sidebar('sidebar-2'); ?> -------------------------------------------------------------------- Can you help me plz? Sam Quote Link to comment Share on other sites More sharing options...
falkencreative Posted February 16, 2014 Report Share Posted February 16, 2014 I was going to respond to your email, but doing it here makes more sense in case others run into the same thing. the get_sidebar() function loads a sidebar.php file within your theme. Get_sidebar() loads sidebar.php, get_sidebar('sidebar-2') would load sidebar-2.php, etc. So if you want to use those functions, you have to make sure that the correct files are in place. Within your sidebar.php/sidebar-2.php, you'd want to have the dynamic_sidebar() call to load the correct sidebar. It's a bit hard to tell based on your code, but I think you have a file named "sidebar2.php", when it should be named "sidebar-2.php" (note the dash). http://codex.wordpress.org/Function_Reference/get_sidebar http://codex.wordpress.org/Function_Reference/dynamic_sidebar Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.