[wp-hackers] ordering by a custom field

Brian Fidler fidler.brian at gmail.com
Thu May 13 14:06:44 UTC 2010

Thanks Mike, I may have some questions on how to implement it.

On Wed, May 12, 2010 at 10:39 PM, Mike Schinkel <mikeschinkel at newclarity.net
> wrote:

> On May 13, 2010, at 12:22 AM, Brian Fidler wrote:
> >
> >   - I have a second custom field in my posts that allows me to set
> >   display_order. Instead of ending my query with ORDER BY
> >   wp_posts.post_title ASC, I'd like to order by the custom field
> >   "display_order"
> What will your custom field's value be?  The name of a field in the posts
> table, or something else?  If the former, I assume there's a finite set of
> options which you would test against (otherwise you might end up having a
> SQL injection vulnerability?)
> > and secondly, is there a simpler way to run this query using wpdb class?
> What about it do you want to be simpler?   AFAICT NextGen doesn't give you
> hooks into their queries so you'll have to do it with SQL.
> Anyway, here's a standalone file you can put in your root and I think it
> should give you want you want, minus the display order I haven't implemented
> yet.  Let me know if this is what you are looking for?
> http://wordpress.pastebin.com/79QDM7Ng
> HTH.
> -Mike
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list