Twenty Ten child theme has post on an inner page. Cant get that page to use my desired template

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.

Read More

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.

Related posts

Leave a Reply

2 comments

  1. This is the wrong usage of using get_template_part as below:

    <?php get_template_part(‘sidebar’,2); ?>
    

    This is the correct one. (Since the file name was sidebar-2.php.)

    <?php get_template_part('sidebar','2'); ?>
    

    This also the correct one. (More direct approach)

    <?php get_template_part('sidebar-2'); ?>
    

    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