please take a moment to look at my code
Code: Select all
<?php
if ($location != '')
{
$loc = "AND pm.meta_value = '$location'";
}
if ($beds != '')
{
$bed = "AND pm.meta_value = '$beds'";
}
if ($price != '')
{
$pri = "AND pm.meta_value = '$price'";
}
$query = "SELECT the_posts.*
FROM wp_posts the_posts, wp_postmeta pm
WHERE the_posts.id = pm.post_id AND
the_posts.id IN (
SELECT xposts.id
FROM wp_posts xposts, wp_term_relationships catspost
WHERE catspost.object_id = xposts.id
AND catspost.term_taxonomy_id IN ($cat_id)
) AND
((
pm.meta_key = 'state_value'
I WANT TO PUT THE $LOC VARIABLE HERE
) OR
(
pm.meta_key = 'price_value'
I WANT TO PUT THE $PRI VARIABLE HERE
) OR
(
pm.meta_key = 'beds_value'
I WANT TO PUT THE $BED VARIABLE HERE
))
GROUP BY the_posts.id;
";
$pageposts = $wpdb->get_results($query, OBJECT);
?>Code: Select all
$query = "SELECT the_posts.*
FROM wp_posts the_posts, wp_postmeta pm
WHERE the_posts.id = pm.post_id AND
the_posts.id IN (
SELECT xposts.id
FROM wp_posts xposts, wp_term_relationships catspost
WHERE catspost.object_id = xposts.id
AND catspost.term_taxonomy_id IN ($cat_id)
) AND
((
pm.meta_key = 'state_value'
". $loc ."
) OR
(
pm.meta_key = 'price_value'
". $pri ."
) OR
(
pm.meta_key = 'beds_value'
". bed ."
))
GROUP BY the_posts.id;
";Many thanks.