[wp-hackers] Oddball query question

Shelly wordpress at anekostudios.com
Sat Oct 25 20:58:53 GMT 2008

Okay.  This is a seriously weird question, and I don't even know if it  
can be done - but here goes.

I'm finishing up a (free, I should mention - I don't want you all to  
think I'm making $$ off your good names :) )  site for a local non- 
profit here in town.  They have a monthly newsletter that they like to  
put online - currently it's done in Microsoft Word (gah!  It's  
terrible) and I'm working on bringing them out of 1992.

So these guys elect a new board member to each position every 2  
years.  The actual *positions* stay the same, but the *people* in them  
change.  Due to this fact, I've created user logins that reflect the  
positions available.  Each board position writes a section to the  
newsletter every month, which starts out with the President first  
(monthly "hello" message) and then goes on to the vice president, the  
civics coordinator, fundraising, etc.

(Yes, there is a point to me telling you this.)

Right now, I'm using a tag archive to determine the newsletters  
pages.  Some of the board positions have running articles which stay  
the same throughout the year, but most of them put in something new  
every month.  (some only create one post that's only to show up in one  
month and never again).  So this knocks out the idea of ordering by  
date - because in some cases,  when a post is written in September  
(the beginning of their year), it's unchanged through to July.  So it  
seemed to make more sense to *tag* them with what month/year they  
belong to, rather than order by date and write the same post over and  
over again.  Because of this, I also had to edit the tag archive with  
a query - because the site is set to show the default 10 posts, but  
the newsletter needs to show *all* posts for it's tag on a page.  So I  
had to do a custom query that matched the current month to it's tag  
(because there's not always the same post count from month to month),  
and I don't want posts from September showing up in October.

So right now, it's set to use a month/year tag for posts so they show  
up in the proper page (tag archive).  I can't order the posts by date  
(for reasons stated above).  Each user also has a category that they  
are bound to (using a plugin) so when they write, they are ensured to  
post is the proper category.  But I can't order the posts by Category  
ID or category name (as far as I know anyway - ordering by Category  
would work, but I don't think that's a parameter that's accepted by  
queries right now, plus aren't tags a form of categories?  That would  
make the database's head explode.), so I'm thinking ordering by author  
is my best bet.  So I did that - ordered the posts by Author ID.   
Works great.

*however* there are times when new positions are added, and sometimes  
a few get removed.  So this screws up my order - because if I add a  
new position, and it needs to show up between two other positions that  
already exist, it shows at the end instead of where it needs to go.   
What I *need* is somehow to order by my own custom-defined order  
string.  Right now, I'm pulling it off my exporting the database and  
reassigning author ID's so they show up in the proper order, and then  
importing the new data back in.  *I'm* fine with doing this, but when  
the club has people who are currently using Microsoft Word to do their  
website, and don't even know what "anchor tag" means...you know this  
ain't gonna work.

So finally we get to my actual question (sorry all, I feel like it's  
better to have too much info than not enough!) - is there a way to set  
my order in a custom manner?  Currently the query that's working is  

  $path = $_SERVER["REQUEST_URI"];
  list($root,$tag,$tagname) = explode('/', $path);

But I need something like this:

$path = $_SERVER["REQUEST_URI"];
list($root,$tag,$tagname) = explode('/', $path);

Where "$order" would be my own custom arrangement of authors be it by  
name or ID.  It just can't be rand(), ASC or DESC, but instead a  
specific order I define (preferably by nicename) and give to the  
$order variable.

Is there a way to do that?  or am I just dreaming?  I was thinking if  
I could somehow pull in the list of all authors in some kind of array  
(wp_list_authors('echo=0')?  maybe?) and then order the key/value  
pairs as variables, I could do it that way, but I feel like a complete  
dolt right now.  I'm just trying anything I can think of right now.

Anyway, if you haven't fallen asleep reading, I'd appreciate any  
prodding or ideas you all might have on this.


More information about the wp-hackers mailing list