[wp-hackers] ordering by a custom field
Mike Schinkel
mikeschinkel at newclarity.net
Thu May 13 05:39:04 UTC 2010
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
More information about the wp-hackers
mailing list