我有侧边栏,当我向其中添加组件时,标题会添加到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; ?>
答案 0 :(得分:0)
要在sidebar.php中使用 wp_list_categories 和 wp_get_archives ,您可以关注 wp_list_categories和wp_get_archives。
如果您的主题支持动态侧边栏,则可以从sidebar.php中删除wp_list_categories
和wp_get_archives
函数调用,并可以使用WordPress管理中的动态窗口小部件&gt;外观&gt;小部件并将Categories
和Archives
小部件添加到侧边栏。
这只是一个示例,基本上位于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_title
和after_title
留空如下
'before_title' => '',
'after_title' => ''
然后你的h2
将会消失。
注意:在您的问题中,您提到了h3
,但在生成的HTML代码中,我看到了h2
。