我有侧栏,当我向它添加组件时,标题被添加到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; ?>发布于 2012-04-10 04:47:34
要在sidebar.php中使用wp_list_categories和wp_get_archives,可以使用和。
如果您的主题支持动态侧边栏,那么您可以从sidebar.php中删除wp_list_categories和wp_get_archives函数调用,并可以从WordPress管理>外观>小部件中使用动态小部件,并将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,但在生成的代码中我看到了h2。
https://stackoverflow.com/questions/10079227
复制相似问题