[wp-hackers] meta_value contains text
Jörn Röder
kontakt at joernroeder.de
Sun Aug 16 21:22:25 UTC 2009
Hi,
Thanks for your constructive reply…
Is there a way to add more than one meta_key – meta_value Pair to the
query?
If i try
$where .= " AND ( wp_pm.meta_key = '$key' AND wp_pm.meta_value LIKE('%
$val%') ) AND wp_pm.meta_value = 'foo' ";
i get no more results…
Jörn
Am 16.08.2009 um 23:06 schrieb Ashok Padda:
> @ Scribu,
>
> Thank you, for pointing us in the right direction. Though,
> posts_where is
> updating the where condition we also need to join wp_postmeta table,
> here.
> So, I think we need to add posts_join filter, too. Please correct me
> if I'm
> wrong.
>
> @ Jorn,
>
> Following plugin worked for me.
> -----------------------------x-----------------------------
> $my_metavalue = 'blue sky';
> add_filter('posts_join', 'my_join');
> add_filter('posts_where', 'my_where');
>
> function my_join( $join ) {
> global $wpdb;
> $join .= " LEFT JOIN " .$wpdb->postmeta. " ON " .$wpdb->posts. ".ID="
> .$wpdb->postmeta. ".POST_ID";
> return $join;
> }
>
> function my_where( $where ) {
> global $my_metavalue;
> $where .= " and meta_value like '" .$my_metavalue. "'";
> return $where;
> }
> -----------------------------x-----------------------------
>
> +Ashok
>
> On Mon, Aug 17, 2009 at 12:39 AM, scribu <scribu at gmail.com> wrote:
>
>> Or, instead of hacking a core file, you could use the 'posts_where'
>> filter
>> and add a condition like:
>>
>> AND meta_value LIKE('New%');
>>
>> --
>> http://scribu.net
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
> _______________________________________________
> 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