[wp-hackers] Feature Request: control of ORDER BY in query...

David Chait davebytes at comcast.net
Wed Mar 2 19:33:57 GMT 2005


Wish I had tracked the alpha/beta process, as this is now making me crazy... 
;)

I have a particular 'sticky' posts implementation that I'm trying to adapt 
over to 1.5.  (Please, don't point me to Adhesive.)  Unfortunately, while 
the team did a great job of >starting< to factor the query for plugins to 
adjust, only JOIN and WHERE are filtered.  I added a three line change to 
add a default $orderby variable, a filter call to allow for modification, 
and change the $request to do ORDER BY ".$orderby."...  I'd like to propose 
such a change get into the next feature-enhancement release.

I had looked at using a meta field for doing this stuff, which is basically 
what Adhesive does, but it is overly hacky to do.  In my 'branched' 
CHAITGEAR code, I modified the post_status field to have a 'sticky' status, 
and updated ALL the touchpoints that used post_status.  Adhesive basically 
makes the main post request a null query by adding a "AND 0=1" into the 
query, then generates a new query after the fact using a lookup into the 
meta table.

In my new CG-PostOrder plugin (trying to 'plugin-ify' all my custom code to 
move to 1.5...), I have a simple separate table (which should always be only 
a handful of entries) that simply associates a post-order value (1-n) with a 
post-ID.  With the above $orderby mod, works like a charm.  I like having it 
separate personally, and it allows for a single-query solution, rather than 
querying for what posts are tagged, then using that as a modifier in a 
re-run query.

(BTW, nothing against Adhesive!  It gets the job done, and is a real neat 
trick to boot!)

Thoughts?  I know the more we filter the query, the more plugins can stomp 
on each other.  But seems that the sort-ordering is as reasonable a filter 
as where and joins...

I can trac this (or whatever is being used these days.. ;) ).

-d 



More information about the hackers mailing list