Adding Sidebars
-
Hi There:
Hoping somebody might be able to help troubleshoot adding sidebars to my site. Using the Themetrust Hardy theme.
https://74.205.124.17/~centerrocks/?page_id=972
I’d like to be able to customize a sidebar for each navbar category, i.e. “ABOUT” and “AWARDS & GRANTS” and so on.
I started with “ABOUT,” adding a new php page template called “page-about.php.”
<?php /* Template Name: About */ ?> <?php get_header(); ?> <?php if(!is_front_page()):?> <div id="pageHead"> <div class="inside"> <h1><?php the_title(); ?></h1> <?php $page_description = get_post_meta($post->ID, "_ttrust_page_description", true); ?> <?php if ($page_description) : ?> <p><?php echo $page_description; ?></p> <?php endif; ?> </div> </div> <?php endif; ?> <div class="wrap"> <div class="middle clearfix"> <div id="content" class="twoThirds clearfix"> <?php while (have_posts()) : the_post(); ?> <div <?php post_class('clearfix'); ?>> <?php the_content(); ?> </div> <?php comments_template('', true); ?> <?php endwhile; ?> </div> <?php get_sidebar('sidebar_2'); ?> </div> </div> <?php get_footer(); ?>
Then I duplicated the sidebar template, calling it “sidebar_2.php.”
<div id="sidebar_2" class="clearfix"> <?php if(is_author()) : ?> <div class="widgetBox sidebarBox clearfix"> <h3><?php _e('Author Info', 'themetrust'); ?></h3> <?php global $wp_query; $current_author = $wp_query->get_queried_object(); ?> <?php echo get_avatar( $current_author->user_email, '80' ); ?> <p><?php echo $current_author->description; ?></p> </div> <?php endif; ?> <?php if(is_archive() && is_active_sidebar('sidebar_posts')) : dynamic_sidebar('sidebar_posts'); elseif(is_home() && is_active_sidebar('sidebar_posts')) : dynamic_sidebar('sidebar_posts'); elseif(is_single() && is_active_sidebar('sidebar_posts')) : dynamic_sidebar('sidebar_posts'); elseif(is_page() && is_active_sidebar('sidebar_pages')) : dynamic_sidebar('sidebar_pages'); elseif(is_search() && is_active_sidebar('sidebar_posts')) : dynamic_sidebar('sidebar_pages'); elseif(is_front_page() && is_active_sidebar('sidebar_home')) : dynamic_sidebar('sidebar_home'); else : ?> <?php if (!dynamic_sidebar('sidebar_2')) ;?> <?php endif; ?> </div><!-- end sidebar -->
These were each modified based on my theme’s files.
On the back end, I’ve been able to nest pages under the About template. And in the widgets menu, I see the Sidebar 2 and I can drag and drop widgets beneath it. However, those widgets do not appear on the page after reloading.
Anyone have any tips? Thanks so much for your time.
- The topic ‘Adding Sidebars’ is closed to new replies.