WordPressMU – get blog list, alphabetically sorted by blogname

In WordPress MU, I’ve tried writing my own query for this but can’t seem to get all of the joins I really need. The result set I’m looking for would be something like:

blog_id
blog name
blog path
owner first name
owner last name

and return it all alphabetically, by blog name. The trouble I’m having is that the first and last name of the blog owner are in wp_usermeta, the blog id and path are in wp_blogs, and the blog name is in wp_[blog id here]_options, with wp_usermeta requiring the user ID from wp_users.

Read More

Is it possible to join all of this in one query?

Related posts

Leave a Reply

1 comment

  1. There is not a way to combine all of the information into one result set because of the way WPMU handles the database table names.

    The best solution I have come up with is some PHP logic that gets the blogs from the wp_blogs table, uses the IDs there to gather information from the wp_X_options tables, and then builds up the information I need. It’s the same reason there is no good way to get a list of all the posts across all of the blogs with just a query. You need backend logic to build the query based on the blogs in wp_blogs.