return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>multisite - Need help sorting "My Sites" Alphabetically
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

multisite - Need help sorting "My Sites" Alphabetically

programmeradmin1浏览0评论

I have 40+ sites showing up in the "My Sites" page with more planned. Unfortunately WordPress doesn't sort them alphabetically, and that makes it a pain to move from site to site during routine updates and maintenance. I've tried adding

asort($blogs);

to wp-admin/my-sites.php, but that doesn't help either. And regardless, I'd rather do this using a filter in functions.php rather than modifying a core file. Making the issue even more complex is the fact that the list is split into four columns, and while a horizontal alphabetical ordering would be a huge improvement, vertical (by column) would be much, much better.

I've been searching for answers for this for a while and coming up empty, so any help would be appreciated. (My PHP is pretty basic, so spelling out the answer would definitely be appreciated.)

I have 40+ sites showing up in the "My Sites" page with more planned. Unfortunately WordPress doesn't sort them alphabetically, and that makes it a pain to move from site to site during routine updates and maintenance. I've tried adding

asort($blogs);

to wp-admin/my-sites.php, but that doesn't help either. And regardless, I'd rather do this using a filter in functions.php rather than modifying a core file. Making the issue even more complex is the fact that the list is split into four columns, and while a horizontal alphabetical ordering would be a huge improvement, vertical (by column) would be much, much better.

I've been searching for answers for this for a while and coming up empty, so any help would be appreciated. (My PHP is pretty basic, so spelling out the answer would definitely be appreciated.)

Share Improve this question asked Nov 30, 2011 at 2:00 SamSam 3671 gold badge4 silver badges14 bronze badges 2
  • It is not recommended to change core WordPress files other than wp-config.php. – Pontus Abrahamsson Commented Jul 31, 2012 at 15:10
  • @PontusAbrahamsson, that’s what he said in the second paragraph. – Synetech Commented Apr 5, 2013 at 18:33
Add a comment  | 

2 Answers 2

Reset to default 13

Easy one.

<?php
/*
Plugin Name: Sort My-Sites
Description: Sorts the My Sites listing on both the page and in the 3.3 admin bar dropdown
Author: Otto
*/

add_filter('get_blogs_of_user','sort_my_sites');
function sort_my_sites($blogs) {
        $f = create_function('$a,$b','return strcasecmp($a->blogname,$b->blogname);');
        uasort($blogs, $f);
        return $blogs;
}

Edit: If you want a PHP 7 version:

add_filter('get_blogs_of_user', function( $blogs ) {
    uasort( $blogs, function( $a, $b ) { 
        return strcasecmp( $a->blogname, $b->blogname );
    });
    return $blogs;
});

This plugin does the job too:

Reorder My Sites

For WordPress Multisite. Reorders the My Sites dropdown menu in the Admin Bar alphabetically. It keeps the main blog at the top.

发布评论

评论列表(0)

  1. 暂无评论