我想我知道我在找什么。我把从我的主题部分中提取的一些代码放在一起,给你一个例子。
For the functions.php:
<?php
add_action( \'after_setup_theme\', \'ideatree_init\' );
if ( ! function_exists( \'ideatree_init\' ) ):
function ideatree_init() {
// REGISTER THE NAV MENUS (3 in this case)
add_action( \'init\', \'register_my_menus\' );
function register_my_menus() {
register_nav_menus(
array(
\'main\' => \'main\' ,
\'secondary\' => \'secondary\',
\'tertiary\' => \'tertiary\'
)
);
}
// REGISTER THE SIDBARS
if ( !function_exists(\'ideatree_widgets_init\') ) {
function ideatree_widgets_init() {
register_sidebar( array(
\'name\' => __( \'main-widget\', \'ideatree\'),
\'id\' => \'main-widget\',
\'description\' => \'The Main widget\', \'ideatree\' ,
\'before_widget\' => \'<ul><li id="%1$s" class="widget-container %2$s">\',
\'after_widget\' => \'</li></ul>\',
\'before_title\' => \'<h3 class="widgettitle">\',
\'after_title\' => \'</h3>\',
) );
register_sidebar( array(
\'name\' => \'showcase-widget\', \'ideatree\',
\'id\' => \'showcase-widget\',
\'description\' => \'The showcase-widget\', \'ideatree\' ,
\'before_widget\' => \'<ul><li id="%1$s" class="widget-container %2$s">\',
\'after_widget\' => \'</li></ul>\',
\'before_title\' => \'<h3 class="widgettitle">\',
\'after_title\' => \'</h3>\',
) );
register_sidebar( array(
\'name\' => \'First Footer Widget\', \'ideatree\',
\'id\' => \'first-footer-widget\',
\'description\' => \'The first footer widget\', \'ideatree\' ,
\'before_widget\' => \'<li id="%1$s" class="widget-container %2$s">\',
\'after_widget\' => \'</li>\',
\'before_title\' => \'<h3 class="widgettitle">\',
\'after_title\' => \'</h3>\',
) );
register_sidebar( array(
\'name\' => \'Second Footer Widget\', \'ideatree\',
\'id\' => \'second-footer-widget\',
\'description\' => \'The second footer widget\', \'ideatree\',
\'before_widget\' => \'<li id="%1$s" class="widget-container %2$s">\',
\'after_widget\' => \'</li>\',
\'before_title\' => \'<span class="widgettitle">\',
\'after_title\' => \'</span>\',
) );
register_sidebar( array(
\'name\' => \'Third Footer Widget\', \'ideatree\',
\'id\' => \'third-footer-widget\',
\'description\' => \'The third footer widget\', \'ideatree\',
\'before_widget\' => \'<li id="%1$s" class="widget-container %2$s">\',
\'after_widget\' => \'</li>\',
\'before_title\' => \'<h3 class="widgettitle">\',
\'after_title\' => \'</h3>\',
) );
}
add_action( \'widgets_init\', \'ideatree_widgets_init\' );
}
//===============\\\\ VARIOUS WP THEME SUPPORTS //===================
if ( ! isset( $content_width ) ) $content_width = 600;
add_theme_support( \'post-thumbnails\' );
add_image_size( \'bigmutha\',580, 180, true ); //Can be used for Portfolio etc...
add_theme_support(\'automatic-feed-links\');
}
endif;
?>
For the sidebar.php:
<div id="sidebar">
<?php /** Home Page Sidebar */
if ( is_page(\'Home\') ) {
?>
<div id="main-sidebar">
<?php if ( ! dynamic_sidebar( \'main-widget\' ) ) :
endif; ?>
</div>
<?php /** showcase page sidebar */ }
if ( is_page(\'showcase\') ) {
?>
<div id="showcase-sidebar">
<?php if ( ! dynamic_sidebar( \'showcase-widget\' ) ) :
endif; ?>
</div>
<?php } ?>
</div>
The footer.php file:
<div id="footer">
<div class="left-footer">
<?php if ( function_exists ( dynamic_sidebar(3) ) ) : ?>
<?php dynamic_sidebar (3); ?>
<?php endif; ?>
</div>
<div class="middle-footer">
<?php if ( function_exists ( dynamic_sidebar(4) ) ) : ?>
<?php dynamic_sidebar (4); ?>
<?php endif; ?>
</div>
<div class="right-footer">
<?php if ( function_exists ( dynamic_sidebar(5) ) ) : ?>
<?php dynamic_sidebar (5); ?>
<?php endif; ?>
</div>
</div><!-- End Footer -->
<?php wp_footer(); ?>
</body>
</html>
您应该首先在测试服务器上进行测试。正如我提到的,这是从两个不同的主题中提取出来的,没有一起测试过。不过这对你应该有用。如果你有任何问题,请告诉我。