Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a WP_Query with meta_query filter on meta_value.

if( ($capacity != '') && ($capacity > 0) ) $filters[] = array('key' => 'mb_capacity','compare' => '>','value' => $capacity, 'type' => 'NUMERIC');
and then later i set the  'meta_query' => $filters of the query

The custom field mb_capacity represents an number but WP store it as a String. I was thinking the "type=>'numeric'" option will handle that, but unfortunatly it doesn't work, the comparison still be done on String instead of Integer.

Is there any solution to that problem ?

Note that i'm using WP 3.2.1.

Many thanks for any suggestions

share|improve this question

closed as too localized by toscho Feb 18 '13 at 23:53

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Can you provide some more information? Which values are you having problems with? The code you showed should work as far as I see. The 'type' => 'NUMERIC' part causes the meta_value to be cast to a number in SQL: CAST(wp_postmeta.meta_value AS SIGNED), before being compared. –  Geert Dec 8 '11 at 15:09

Browse other questions tagged or ask your own question.