If the variable you are storing in meta_value
were an integer, you would not be able to store it as ’02’. So, apparently, your are storing a string. This indeed gives different orders depending on whether you store ’02’ or ‘2’, as is described under meta_value
in the codex on WP_Query
.
So, as the codex says, you must force the string to be converted to integers by ordering with meta_value_num
or by additionally specifying meta_type=NUMERIC
.