I have a child theme based on Twenty Ten.
I have split out the sidebar and secondary side bar so they can be used on different pages.
sidebar.php file:
<div id="primary" class="widget-area" role="complementary">
<ul class="xoxo">
<?php
/* When we call the dynamic_sidebar() function, it'll spit out
* the widgets for that widget area. If it instead returns false,
* then the sidebar simply doesn't exist, so we'll hard-code in
* some default sidebar stuff just in case.
*/
if ( ! dynamic_sidebar( 'primary-widget-area' ) ) : ?>
<li id="search" class="widget-container widget_search">
<?php get_search_form(); ?>
</li>
<li id="archives" class="widget-container">
<h3 class="widget-title"><?php _e( 'Archives', 'twentyten' ); ?></h3>
<ul>
<?php wp_get_archives( 'type=monthly' ); ?>
</ul>
</li>
<li id="meta" class="widget-container">
<h3 class="widget-title"><?php _e( 'Meta', 'twentyten' ); ?></h3>
<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<?php wp_meta(); ?>
</ul>
</li>
<?php endif; // end primary widget area ?>
</ul>
</div><!-- #primary .widget-area -->
sidebar-2.php
<?php
// A second sidebar for widgets, just because.
if ( ! dynamic_sidebar( 'secondary-widget-area' ) ) : ?>
<div id="secondary" class="widget-area" role="complementary">
<ul class="xoxo">
<?php dynamic_sidebar( 'secondary-widget-area' ); ?>
</ul>
</div><!-- #secondary .widget-area -->
<?php endif; ?>
I want to display sidebar-2 (the secondary sidebar) in my post pages. I call them using:
<?php get_template_part(âsidebarâ,2); ?>
(in the following files: archive.php, post.php, author.php, category.php)
instead of <?php get_sidebar(); ?>
I’ve set my ‘Settings’ for ‘Reading’ so that the page is for displaying ‘Posts’.
When I visit the page, it displays the primary sidebar.
You can see for yourself at http://akhomehealth.com/newsletter/
Sidebar should show search, archive, category and recent posts.
try this instead
<?php get_sidebar(2); ?>
This is the wrong usage of using get_template_part as below:
This is the correct one. (Since the file name was sidebar-2.php.)
This also the correct one. (More direct approach)
I noticed that you type the symbol of â and â inside the code âsidebarâ. It should be ‘sidebar’. Or else it may not working. You should aware the symbol on your keyboard