[wp-hackers] Please Help: How to compare 2 float values in meta_value column?
Adriaan Pelzer
adriaan.pelzer at gmail.com
Wed Feb 3 14:11:52 UTC 2010
Convert the meta_key strings to floats with a cast. Something like this:
$price = (float) get_post_meta ($post->ID, "price", TRUE);
The value of price is now a float, and can be compared to your limits:
if (($price > 23) && ($price < 41)) {
...
}
Adriaan Pelzer
PIT Productions
+2712 651 2432
On Wed, Feb 3, 2010 at 3:02 PM, babyboy808 <hi at eirestudio.net> wrote:
>
> Hi Guys,
>
> I have about 100 posts in wordpress, all with a meta_key of price and a
> value. How would I go about searching through all posts with a value
> between
> 23.00 and 41.00 for example?
>
> I know that 'meta_compare ' treats 'meta_value' as a string, so I can't use
> this to solve my problem.
>
> Anybody have any clues?
>
> Thanks
> --
> View this message in context:
> http://old.nabble.com/Please-Help%3A-How-to-compare-2-float-values-in-meta_value-column--tp27435706p27435706.html
> Sent from the Wordpress Hackers mailing list archive at Nabble.com.
> _______________________________________________
> 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