61,115
社区成员
发帖
与我相关
我的任务
分享
#sidebar #widget_posts ul li, #sidebar #widget_comments ul li, #sidebar #widget_categories ul li {
background: url(images/list_icon.gif) no-repeat left;
/*list-style-type: circle;*/
padding-left:10px;
}
<div id="sidebar">
<ul>
<?php
if (is_home()) {
$posts_widget_title = 'Random Posts';
} else {
$posts_widget_title = 'Recent Posts';
}
?>
<li id="widget_posts">
<h2><?php echo $posts_widget_title; ?></h2>
<ul>
<?php
if (is_single()) {
$posts = get_posts('numberposts=6&&orderby=post_date');
} else {
$posts = get_posts('numberposts=6&&orderby=rand');
}
foreach($posts as $post) {
setup_postdata($post);
echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
}
$post = $posts[0];
?>
</ul>
</li>
<!-- end of the random/recent posts -->
<!-- start of the widget_comments -->
<li id="widget_comments">
<h2>Recent Comments</h2>
<ul><?php get_recent_comments(); ?></ul>
<!--<ul><?php wp_recentcomments(); ?></ul>-->
</li>
<!-- end of the widget_comments -->
<!-- start of the widget_categories -->
<li id="widget_categories">
<h2>Categories</h2>
<ul><?php wp_list_categories('show_count=1&title_li=') ?></ul>
</li>
<!-- end of the widget_categories -->
</ul>
</div>
<!-- start of the random/recent posts -->
<li id="widget_posts">
<h2>Random Posts</h2>
<ul>
<li><a href="http://127.0.0.1/wordpress/?p=3">寄语新博开张</a></li><li><a href="http://127.0.0.1/wordpress/?p=37">生活方式</a></li><li><a href="http://127.0.0.1/wordpress/?p=101">理清思绪</a></li><li><a href="http://127.0.0.1/wordpress/?p=102">One year</a></li><li><a href="http://127.0.0.1/wordpress/?p=33">沟通从心开始</a></li><li><a href="http://127.0.0.1/wordpress/?p=12">弟弟启程了</a></li> </ul>
</li>
<!-- end of the random/recent posts -->
<!-- start of the widget_comments -->
<li id="widget_comments">
<h2>Recent Comments</h2>
<ul> <li><a href="http://127.0.0.1/wordpress/?p=96#comment-85" title="信息周刊:车轮上的携程们, 2009年07月31日">admin</a>: @admin 看下这个显示最新评论的插件如何撒?</li>
<li><a href="http://127.0.0.1/wordpress/?p=96#comment-83" title="信息周刊:车轮上的携程们, 2009年07月31日">admin</a>: let’s have a try</li>
</ul>
<!-- end of the widget_comments -->
<!-- start of the widget_categories -->
<li id="widget_categories">
<h2>Categories</h2>
<ul> <li class="cat-item cat-item-39"><a href="http://127.0.0.1/wordpress/?cat=39" title="查看 WEB2.0 下的所有文章">WEB2.0</a> (2)
</li>
<li class="cat-item cat-item-43"><a href="http://127.0.0.1/wordpress/?cat=43" title="查看 wordpress 下的所有文章">wordpress</a> (3)
</li>
<li class="cat-item cat-item-1"><a href="http://127.0.0.1/wordpress/?cat=1" title="查看 未分类 下的所有文章">未分类</a> (21)
</li>
</ul>
</li>
<!-- end of the widget_categories -->
<style>
#sidebar #widget_posts ul li, #sidebar #widget_comments ul li, #sidebar #widget_categories ul li {
background:url(images/list_icon.gif) no-repeat left;
/*list-style-type: circle;*/
padding-left:10px;
}
</style>
<div id="sidebar">
<ul>
<li id="widget_posts">
<h2>Random Posts</h2>
<ul>
<li><a href="http://127.0.0.1/wordpress/?p=3">寄语新博开张</a></li>
<li><a href="http://127.0.0.1/wordpress/?p=37">生活方式</a></li>
<li><a href="http://127.0.0.1/wordpress/?p=101">理清思绪</a></li>
<li><a href="http://127.0.0.1/wordpress/?p=102">One year</a></li>
<li><a href="http://127.0.0.1/wordpress/?p=33">沟通从心开始</a></li>
<li><a href="http://127.0.0.1/wordpress/?p=12">弟弟启程了</a></li> </ul>
</li>
<!-- end of the random/recent posts -->
<!-- start of the widget_comments -->
<li id="widget_comments">
<h2>Recent Comments</h2>
<ul> <li><a href="http://127.0.0.1/wordpress/?p=96#comment-85" title="信息周刊:车轮上的携程们, 2009年07月31日">admin</a>: @admin 看下这个显示最新评论的插件如何撒?</li>
<li><a href="http://127.0.0.1/wordpress/?p=96#comment-83" title="信息周刊:车轮上的携程们, 2009年07月31日">admin</a>: let’s have a try</li>
</ul>
<!-- end of the widget_comments -->
<!-- start of the widget_categories -->
<li id="widget_categories">
<h2>Categories</h2>
<ul> <li class="cat-item cat-item-39"><a href="http://127.0.0.1/wordpress/?cat=39" title="查看 WEB2.0 下的所有文章">WEB2.0</a> (2)
</li>
<li class="cat-item cat-item-43"><a href="http://127.0.0.1/wordpress/?cat=43" title="查看 wordpress 下的所有文章">wordpress</a> (3)
</li>
<li class="cat-item cat-item-1"><a href="http://127.0.0.1/wordpress/?cat=1" title="查看 未分类 下的所有文章">未分类</a> (21)
</li>
</ul>
</li>
</ul>
</div>