列出网络上最近的25个博客 时间:2012-08-02 作者:Ronin 我需要列出最近在网络上的25个博客及其标题。如何编辑此代码?$bcount = get_blog_count(); global $wpdb; $blogs = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE spam = \'0\' AND deleted = \'0\' and archived = \'0\' and public=\'1\'")); if(!empty($blogs)){ ?><ul class="menu"><?php foreach($blogs as $blog){ $details = get_blog_details($blog->blog_id); if($details != false){ $addr = $details->siteurl; $name = $details->blogname; if(!(($blog->blog_id == 1)&&($show_main != 1))){ ?> <li class="menu-item<?php if($counter == get_current_blog_id()){ echo \' current-menu-item\';}?>"> <a href="<?php echo $addr; ?>"><?php echo $name;?></a> </li> <?php } } } ?></ul><?php } 1 个回复 SO网友:nvartolomei 您只需修改查询即可获得前25个匹配项SELECT * FROM $wpdb->blogs WHERE spam = \'0\' AND deleted = \'0\' and archived = \'0\' and public=\'1\' limit 25.结果已按排序id 什么是自动递增的,你没有什么可担心的。另外请注意,对每个请求执行此类查询不是一个好的做法,您应该缓存它们。 结束 文章导航