[wp-hackers] Function to get posts by meta

Louy Alakkad louy08 at gmail.com
Tue Aug 3 12:06:09 UTC 2010


Well, when i need to do the same, I'm modifying the main query with the
'posts_where' filter, just like how it's done in
Thanks for the sharing anyway ;)


On Tue, Aug 3, 2010 at 2:56 PM, Christian Gundersson <christian at buro2.se>wrote:

> 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
> _______________________________________________
> 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