我的菜单html代码如下:
<div class="menu">
<ul>
<li><a href="index.php" >Home</a></li>
<li><a href="aboutus.php" >About Us</a></li>
<li><a href="services.php" >Services</a></li>
<li><a href="success.php" >Success Stories</a></li>
<li><a href="testimonials.php" >Testimonials</a></li>
<li><a href="contactus.php" >Contact Us</a></li>
</ul>
我已在中注册侧栏
functions.php
如下所示
<?php
$args = array(
\'name\' => __( \'Main Navigation\', \'theme_text_domain\' ),
\'id\' => \'sidebar-navigation\',
\'description\' => \'Main Navigation Container\',
\'class\' => \'\',
\'before_widget\' => \'<div>\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h2 class="widgettitle">\',
\'after_title\' => \'</h2>\' );
register_sidebar( $args );
?>
之后,我调用了动态侧栏
header.php
文件为
<?php dynamic_sidebar(\'sidebar-navigation\'); ?>
但我看不到菜单出现。
SO网友:Overdose
你应该这样钩住它:
function customwidget_init()
{
$args = array(
\'name\' => __( \'Main Navigation\', \'theme_text_domain\' ),
\'id\' => \'sidebar-navigation\',
\'description\' => \'Main Navigation Container\',
\'class\' => \'\',
\'before_widget\' => \'<div>\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h2 class="widgettitle">\',
\'after_title\' => \'</h2>\' );
register_sidebar( $args );
}
add_action( \'widgets_init\', \'customwidget_init\');
请参见
Codex 描述