这个插件可能是最简单的方法。http://wordpress.org/extend/plugins/add-widgets-to-page/
But for a scratch method...
研究主题二十的功能。php文件并查找动态侧栏的注册位置。看起来是这样的:
<?php function twentyten_widgets_init() {
// Area 1, located at the top of the sidebar.
register_sidebar( array(
\'name\' => __( \'Primary Widget Area\', \'twentyten\' ),
\'id\' => \'primary-widget-area\',
\'description\' => __( \'The primary widget area\', \'twentyten\' ),
\'before_widget\' => \'<li id="%1$s" class="widget-container %2$s">\',
\'after_widget\' => \'</li>\',
\'before_title\' => \'<h3 class="widget-title">\',
\'after_title\' => \'</h3>\',
) );
// Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
register_sidebar( array(
\'name\' => __( \'Secondary Widget Area\', \'twentyten\' ),
\'id\' => \'secondary-widget-area\',
\'description\' => __( \'The secondary widget area\', \'twentyten\' ),
\'before_widget\' => \'<li id="%1$s" class="widget-container %2$s">\',
\'after_widget\' => \'</li>\',
\'before_title\' => \'<h3 class="widget-title">\',
\'after_title\' => \'</h3>\',
) );
// Area 3, located in the footer. Empty by default.
//similar code as above
// Area 4, located in the footer. Empty by default.
//similar code as above
// Area 5, located in the footer. Empty by default.
//similar code as above
// Area 6, located in the footer. Empty by default.
//similar code as above
//Your Area 7, copy area 2 above and customize it
}
/** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
add_action( \'widgets_init\', \'twentyten_widgets_init\' );
我在上面的第7区写过,因为第210区包括6个寡妇区。将所有这些复制到主题的函数中。如果还没有php,请删除或添加所需内容。
在要放置自定义区域7的模板文件中使用以下函数调用:
<?php if ( !function_exists(\'dynamic_sidebar\') || !dynamic_sidebar(7) ) : endif; ?>
例如,在主题目录中创建模板文件,并将其用作在WordPress中创建的页面的默认模板。转到外观->小部件并将小部件拖动到区域7,它们将显示在您的页面上。如果您需要另一个小部件区域(动态侧栏),请将7替换为8>
此答案是在的帮助下创建的this post by a guy named Flynn