[wp-hackers] Function to get posts by meta
dennen at gmail.com
Tue Aug 3 12:14:32 UTC 2010
Or this, which lets you specify a custom post type:
On Tue, Aug 3, 2010 at 8:08 AM, Bill Dennen <dennen at gmail.com> wrote:
> Could you use this?
> (string) (optional) The type of post to show. Available options are:
> post - Default
> any - all post types
> Default: post
> $meta_key and $meta_value
> (string) (optional) Only show posts that contain a meta (custom) field
> with this key and value. Both parameters must be defined, or neither
> will work.
> On Tue, Aug 3, 2010 at 7:56 AM, Christian Gundersson <christian at buro2.se> wrote:
>> 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
>> //Christian, Büro 2
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
More information about the wp-hackers