为什么我的h3被添加到wordpress中的li标签内?

时间:2012-04-09 20:15:26

标签: php javascript wordpress

我有侧边栏,当我向其中添加组件时,标题会添加到ul的li项中,使其看起来很难看。我该如何克服这一点。不幸的是,我很少或根本不知道wordpress和php。

这是我如何在firebug中获得它:

<li class="widget widget_categories" id="categories-8"><h2 class="widgettitle">Categories</h2>
        <ul>
    <li class="cat-item cat-item-1"><a title="View all posts filed under Uncategorized" href="http://localhost/wordpress/wordpress/?cat=1">Uncategorized</a>
</li>
        </ul>
</li>

除了一些静态的html ul li之外,这是我在侧边栏中的内容:

<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar() ) : else : ?>
        <ul class="ul-cat">

        <?php wp_list_categories('show_count=1&title_li='); ?> 




        <?php wp_get_archives('type=monthly'); ?> 
</ul>       
        <?php endif; ?>

1 个答案:

答案 0 :(得分:0)

  

要在sidebar.php中使用 wp_list_categories wp_get_archives ,您可以关注   wp_list_categorieswp_get_archives

如果您的主题支持动态侧边栏,则可以从sidebar.php中删除wp_list_categorieswp_get_archives函数调用,并可以使用WordPress管理中的动态窗口小部件&gt;外观&gt;小部件并将CategoriesArchives小部件添加到侧边栏。 这只是一个示例,基本上位于functions.php内,生成动态小部件

if ( function_exists('register_sidebar') )
register_sidebar(array(
    'name' => 'Sidebar',
    'before_widget' => '<li id="%1$s" class="widget %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>'
));

如果您将before_titleafter_title留空如下

'before_title' => '',
'after_title' => ''

然后你的h2将会消失。

注意:在您的问题中,您提到了h3,但在生成的HTML代码中,我看到了h2