Reputation: 144
I am a little unsure how to do a WP_Query to search a meta value of my posts. The meta data includes a persons height. So valid entries would be 5'9"
or 4'11"
and I need to do a Compare-Between.
To make it a bit clearer: I have a filter page. So the user can select the height between 4'0" - 5'9
or 5'9" - 5'11"
The problem is I have the '
and "
symbols. I can remove these. But then it will be searching between 59
and 511
which is not going to work.
Anyone know of a work around?
Upvotes: 0
Views: 39
Reputation: 14381
Save the values in inches.
You could then set up a WP_Query
or a $wpdb
query to fetch your results.
Whenever you are displaying the values on the front end, you convert them back to feet and inches.
update:
function convert_to_feet( $input){
$feet = (int) ($input/12);
$inches = $input%12;
return $feet . "'" . $inches . '"';
}
echo convert_to_feet(71);
Upvotes: 2