Blogname ORDER BY id ASC

时间:2014-04-08 14:21:03

标签: php wordpress

我希望ASC上的所有博客列表和blogname排序。我现在所有的博客,但如何在ASC上进行blogname排序?

<?php 
$blog_list = get_blog_list( 0, 'all' );
krsort($blog_list);
foreach ($blog_list as $blog)

{$blogname = $wpdb->get_results("SELECT option_value FROM wp_".$blog['blog_id'] ."_options WHERE option_name='blogname'");
foreach ($blogname as $name) {
echo '<li class="menu-item">';
echo '<a href="'.$blog['path'].'">'.$name->option_value.'</a>';
echo '</li>';}}?>

2 个答案:

答案 0 :(得分:0)

这应该只是在查询结束时添加ORDER BY。

$blogname = $wpdb->get_results("SELECT option_value FROM wp_".$blog['blog_id'] ."_options WHERE option_name='blogname' ORDER BY option_name ASC");

http://dev.mysql.com/doc/refman/5.1/en/sorting-rows.html

答案 1 :(得分:0)

您可以轻触编辑查询:

{$blogname = $wpdb->get_results("SELECT option_value FROM wp_".$blog['blog_id'] ."_options WHERE option_name='blogname' ORDER BY option_name ASC");