Blog Pile

Wrangling WordPress MultiUser

Besides manually updating six separate instances WordPress (to version 2.6) in the NMC fleet of sites, I also finally paid some over due attention to the version of WordPressMultiUser I have had up since November 2007. This tool some rustling to get it to the right version and also what had not been done in a while- making the front door.

I am hardly a WPmu guru, certainly no bavatuesday… maybe a bavalatethursdaymorning. Most places running WPmu are doing it to provide a blog hosting service, like edublogs or the crazy stuff the Rev does at Mary Washington.

My need was to have a series of separate sites hosted in WordPress w/o having to have an even bigger fleet of separate installs (Heck, maybe one day I can rope them all in under the WPmu hood). No these are all a series of online publications we have done at NMC in the lasy 8 months, all using the slick CommentPress template. Developed by the Institute for the Future of the Book, CommentPress provides a way to post a series of publication chapters as “blog” posts, but the special feature is that comments can be attached to individual chapters.

So we have things like the 2008 Horizon Report in this format as well as the text of a keynote given by Howard Rheingold on Co-Evolution of Technology, Media and Collective Action.

Until just a few minutes ago, these were separate little sites, but now I have at least a crude launch page for the entire WPmu site at http://wp.nmc.org.

Getting here meant first upgrading WPmu from what I had installed, version 1.3.3 to the just released 2.6 version (they bumped the numbers to be in line with the versions of regular WordPress). The documentation on upgrading WPmu is skimpy to say the least; the ReadMe file said it had to be done incrementally from 1.3.3. to 1.5.1 and then to 2.6.

Okay that is not too much.

Except I spent 40 minutes poking arounf the WPmu site and the WP Codex w/o any luck. Finally I tossed a tweet in frustration, closed the lid, and went outside to do some real work. But the twitterverse shined and came through as Kevin Jarret pointed me to the Trac code side.

Doh, right? How the _______ would anyone find that (without friends on twitter).

The upgrade process was pretty easy. Next was the fun part, starting to rip apart the template:

This is just the start.

(A) List of Blogs on Site

One thing I needed was a list of all the blogs on the site (each a different publication), so I reached for the list-all plugin which, as you might guess, returns output of all the blogs on a WPMU site, with some options for the order, and how many it spits out. I just put some code in my index.php template to make a block that would appear above any “posts” as an index to the whole site:

Publications on this site

    ', '', 'last_created');?>

The div was needed to add some styles so it would stand out a bit more. At first nothing happened; I got the header but no lists. I dug in the plugin to find the MySQL query and then ran it manually in phpMyAdmin- and sure enough, it returned no results. Then I looked at the query and my wp_blogs table and realized it had a condition looking for a value of public=1 and in my table, these were all 0s. I can only guess that either my database did not get a right setting or maybe it was a new column added. My hack was to modify values in te database to set all values of public to be 1.

This was fine, but the query in the plugin also was returning a link to this same blog. So it was back to the plugin code, finding the query and adding an extra condition to the query on line 89:

AND blog_id > 1 so the main blog was skipped. That all worked.

The list-all plug in seems like a large chunk of code to do what I can see is a basic query, a lot of the stuff I did as described in WordPress Dissected. I plan to go back and just code in the query, which will allow my to pull and display other data, like the tag line, or the date published, or the number of comments, or…. With some MySQL know how, you can be a god. Sort of.

(b) List of Posts From Within

The next thing I wanted was a piece on the sidebar that would pull in content from among all the published papers within. There are a handful of plugins that do it on the WPMU Dev site, I chose Ada WPMU Recent Posts because it did so as a widget. I’m old school in my templates and have not done much with widgets except when forced to (like on WordPress.com). But since this blog was basic, I thought it would be worthwhile to get some widget experience.

It worked as advertised, and the options in the widget editor let me chose to pull Posts or Pages, and some options for ordering them.

The problem was a date order was not very interesting. When I create these Comment Press sites, I mend up cresting about 5-10 posts in a row in the same blog, because each one is chapter/section. So in this list, the would be all from the same blog because I di each site at different times.

So I tweaked the code slightly, by editing again the MySQL query that grabbed the posts, by changing line 224 in ada_list-all-posts.php (this plug is ironically built on top of the list-all.php plugin I used inn section (A)) which sets the ordering of the results to be in reverse chnronological order– I changed the line that reads:

$post_sql .= " ORDER BY post_date_gmt DESC " . $limit . "";

to read:

$post_sql .= "ORDER BY RAND() " . $limit . "";

so rather than getting 7 or 10 posts in order of most recent, I now have a random selection form across the site.

This is still in play mode. I want to add more that will pull comments form within the site to the front, and eventually some sort of site wide tag thing going.

Wow, I love tinkering in WordPress.

If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
Become a patron at Patreon!
Profile Picture for CogDog The Blog
An early 90s builder of web stuff and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person. And he is 100% into the Fediverse (or tells himself so) Tooting as @cogdog@cosocial.ca

Comments

  1. You’re a bavaeveryday in my book. I do love it when you dissect WordPress, I learn a ton from you every time. The hack to the List All plugin is a useful one, and I now have a project for a nice modified widget featuring random plugin posts on the sidebar of UMW Blogs, thank you very much. I can ee you are getting ready for the WP Camp San Francisco, and I am ever jealous, but do enjoy it when you dig into the code of WordPress, because for all by preaching, ranting, and raving I’m no where near the Jedi that you are. All praise.

    Love and kisses,
    The mighty Reverend!

  2. Started looking at inserting a feed of comments, either latest of random. The hitch to a lot of these is that they have to walk eah blog’s database tables, so a plugin like sitewide comments is handy (it creates a new database table and maintains it as a copy of all comments to all blogs), which means a query then only has to hit one table.

    Another topic of interest would be to make a sitewide RSS feed.

Leave a Reply to Alan Levine aka CogDog Cancel reply

Your email address will not be published. Required fields are marked *