(Moderator\'s note: 最初的标题是“如何在导航栏中创建小部件区域(特定于Genesis)?”(
我正在尝试在导航栏中创建一个小部件区域。我试图改编比尔·埃里克森的优秀教程here 在向导航栏添加静态内容时。
这是我添加到函数中的代码。用于注册和放置小部件区域的php文件:
genesis_register_sidebar(array(
\'name\'=>\'Nav Right\',
\'description\' => \'This is the right section of the navbar.\',
\'before_widget\' => \'<div id="%1$s" class="widget %2$s">\', \'after_widget\' => \'</div>\',
\'before_title\'=>\'<h4 class="widgettitle">\',\'after_title\'=>\'</h4>\'
));
//Adding the widget area to the navbar
add_filter(\'genesis_nav_items\',\'navbar_widget\',10,1);
add_filter(\'wp_nav_menu_items\',\'navbar_widget\',10,1);
function navbar_widget() {
?>
<div class="nav_right">
<?php if (!dynamic_sidebar(\'Nav Right\')) : ?>
<div class="widget">
<h4><?php _e("Nav Right", \'genesis\'); ?></h4>
<p><?php _e("This is a widgeted area which is called Nav Right.", \'genesis\'); ?></p>
</div>
<?php endif; ?>
</div><!-- end .nav-right -->
<?php
}
然而,我最终得到的是:
导航栏外的小部件区域(以及从导航栏中删除的链接-应该有一个主页和关于链接)。
这是html(当我查看页面源代码时):
<body class="home blog logged-in content-sidebar">
<div id="wrap">
<div id="header"><div class="wrap"><div id="title-area"><h1 id="title"><a href="http://travisnorthcutt.com/gateway/" title="Research Valley International Gateway">Research Valley International Gateway</a></h1><p id="description">Just another WordPress site</p></div><!-- end #title-area --><div class="widget-area"></div><!-- end .widget_area --></div><!-- end .wrap --></div><!--end #header-->
<div class="nav_right">
<div class="widget">
<h4>Nav Right</h4>
<p>This is a widgeted area which is called Nav Right.</p>
</div>
</div><!-- end .nav-right -->
<div id="nav"><div class="wrap"></div></div>
关于如何获取创建的新窗口小部件区域的任何建议
<div id="nav"></div>
?