[wp-hackers] Function to get posts by meta
Christian Gundersson
christian at buro2.se
Tue Aug 3 11:56:38 UTC 2010
Hi,
I'm writing a plugin for a client using custom post types and ran across a
situation where I wanted to retrieve post data from posts that shared the
same meta data (key and value). I didn't find anything in Wordpress core or
by searching so I wrote a function for it myself and I'm wondering if it
would be of any interest to anyone else.
The function, as said, takes a meta key and a meta value as argument and
then performs a search for posts that has that exact match. The return value
is an array with the post data.
The code is viewable on github: http://gist.github.com/506224
I have two questions on this though.
1) Have I done the function properly? (I'm fairly new so I'd like some tips
and hints to improve my coding skills on Wordpress)
2) Would this be of any interest for inclusion in Wordpress? And if not, why
not?
Thanks!
Regards,
//Christian, Büro 2
More information about the wp-hackers
mailing list