WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

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