Help with PHP codes for sidebar – not loading widgets!
-
I have googled and read thru multiple guides, mostly same instructions, but I still can’t create a customized sidebar to load widgets on my static Home page (i.e. the landing page ending in “/”). Right now, I can see the sidebar in Appearance->Widgets, but I can’t load images into the sidebar.
I am not trying to become a WP developer, I am just trying to create asimple web site with customized sidebars for infographic slides, one sidebar for each page.
Right now, I have “trashed” Home and recreating it.
Here are the codes I added to functions.php to register homepage_sidebar:
[code]
/**
* AC: added 'Homepage_Sidebar', visible in Appearance->Widgets but not loading widgets
*/function twentyeleven_widgets_init() {
register_widget( 'Twenty_Eleven_Ephemera_Widget' );
register_sidebar(
array(
'name' => __( 'Homepage_Sidebar', 'twentyeleven' ),
'id' => 'homepage_sidebar',
'description' => __( 'Optional 20-11 Template', 'twentyeleven' ),
'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', 'twentyeleven_widgets_init' );
[/code]And here are the codes I added to sidebar.php
I added the check is_home() b/c I only want it to show on Home page.<?php
/**
* Sidebar containing the main widget area
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/$options = twentyeleven_get_theme_options();
$current_layout = $options[‘theme_layout’]; ?><div class=”sidebar homepage_sidebar”>
<?php if ( is_home() && is_active_sidebar(‘homepage_sidebar’)) : ?>
<div id=”sidebar”>
<?php echo(‘homepage_side is active if you see this line.’); ?>
<?php dynamic_sidebar(‘homepage_sidebar’); ?>
</div>
<?php else :?>
<!– display archives and some meta data like login –>
<aside id=”archives” class=”widget”>
<h3 class=”widget-title”><?php _e( ‘Archives’, ‘twentyeleven’ ); ?></h3>-
<?php wp_get_archives( array( ‘type’ => ‘monthly’ ) ); ?>
</aside>
<aside id=”meta” class=”widget”>
<h3 class=”widget-title”><?php _e( ‘Meta’, ‘twentyeleven’ ); ?></h3>-
<?php wp_register(); ?>
- <?php wp_loginout(); ?>
<?php wp_meta(); ?>
</aside>
<?php endif; ?></div>`
The page I need help with: [log in to see the link]
The topic ‘Help with PHP codes for sidebar – not loading widgets!’ is closed to new replies.