Add new Sidebar
-
Hi,
I’m new to WP and have a question related to the Main Sidebar. I’m using Twelve Eleven template which has only one Main Sidebar and I need two.
I’ve modified the function.php file and added the following code which has created new sidebar called Main Sidebar10. I’ve also created a file called sidebar10-page.php and added its reference into the function.php.
My problem is that when I go into a page I can’t see the Main Sidebar10 as option in the Template.
Any suggestion?
Thanks for your help
Marcoregister_sidebar( array(
‘name’ => __( ‘Main Sidebar10’, ‘twentyeleven’ ),
‘id’ => ‘sidebar-10’,
‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => “</aside>”,
‘before_title’ => ‘<h3 class=”widget-title”>’,
‘after_title’ => ‘</h3>’,
-
btw: do not edit Twenty Eleven directly, but create a child theme first, to work with; http://codex.wordpress.org/Child_Themes
the posted code would only bring the new widget area into dashboard – appearance – widgets.
you still need to programm a space to output the widgets into a template or a new sidebar file;
created a file called sidebar10-page.php
what is the code of that file?
(for posting code – see http://codex.wordpress.org/Forum_Welcome#Posting_Code )Hi and thanks for your quick reply.
THis is the code I put in sidebar10-page.php
<?php
/**
* Template Name: Sidebar Template
* Description: A Page Template that adds a sidebar to pages
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/get_header(); ?>
<div id=”primary”>
<div id=”content” role=”main”><?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( ‘content’, ‘page’ ); ?>
<?php comments_template( ”, true ); ?>
<?php endwhile; // end of the loop. ?>
</div><!– #content –>
</div><!– #primary –><?php get_sidebar(); ?>
<?php get_footer(); ?>please read http://codex.wordpress.org/Forum_Welcome#Posting_Code for posting code, and apply those guidelines.
this line
<?php get_sidebar(); ?>will call the default sidebar.php;
to call your new widget area, you need to create a different sidebar file, for example sidebar-ten.php and call it with
<?php get_sidebar('ten'); ?>in this sidebar file, you need to use for instance
<?php dynamic_sidebar('sidebar-10'); ?>
The topic ‘Add new Sidebar’ is closed to new replies.