I have the below GET function that is based on regular WordPress custom field names. When ticked, it sorts all posts that have that custom field value set to 1. It currently works. But, I happen to have two custom fields named: 'free' and 'twofree'
When I tick 'free', it also includes 'twofree' and vica-versa. It does not seem to be case sensitive. Is there any work around to this?
<?php
/* my code starts from here*/
if( isset( $_GET['show'] ) && !empty ( $_GET['show'] ) ){
if( $_GET['show'] == 1 )
$meta_field = 'free';
else if( $_GET['show'] == 4 )
$meta_field = 'sale';
else if( $_GET['show'] == 2 )
$meta_field = 'genuine';
else if ( $_GET['show'] == 'onfire' )
$meta_field = 'onfire';
else if( $_GET['show'] == 5 )
$meta_field = 'twofree';
else if( $_GET['show'] == 3 )
$meta_field = 'onfire';
if( $_GET['show'] == 'sale' )
query_posts('cat='.$cat.'&meta_key='.$meta_field.'&meta_value > 0');
else
query_posts('cat='.$cat.'&meta_key='.$meta_field.'&meta_value>=1');
}
/* my code ends from here*/
?>
EDIT: I have found the problem and it lied in the part
query_posts('cat='.$cat.'&meta_key='.$meta_field.'&meta_value>=1');
I changed it to
query_posts('cat='.$cat.'&meta_key='.$meta_field.'&meta_value=1');