向PHP查询添加多个选项

问题描述:

我有一个房产列表网站,我需要帮助您筛选搜索结果的代码。下面的代码包括所有合同类型为“南部 - 俄勒冈州”的房产。我希望它也包括合同类型=“medford-office”。有人能告诉我如何将其添加到代码?向PHP查询添加多个选项

下面是代码:

<?php 
echo $div; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
query_posts(array('post_type'=>'property','post_status'=>'publish','paged'=>$paged, 
        'author'=>$agent, 'property-contract-type'=>'southern-oregon')); 
if(have_posts()):while(have_posts()):the_post(); 
$property_images = get_post_meta(get_the_ID(),'imic_property_sights',false); 
$total_images = count($property_images); 
$property_term_type = ''; 
$property_area = get_post_meta(get_the_ID(),'imic_property_area',true); 
$property_baths = get_post_meta(get_the_ID(),'imic_property_baths',true); 
$property_beds = get_post_meta(get_the_ID(),'imic_property_beds',true); 
$property_parking = get_post_meta(get_the_ID(),'imic_property_parking',true); 
$property_address = get_post_meta(get_the_ID(),'imic_property_site_address',true); 
$property_city = get_post_meta(get_the_ID(),'imic_property_site_city',true); 
$property_price = get_post_meta(get_the_ID(),'imic_property_price',true); 
$contract = wp_get_object_terms(get_the_ID(), 'property-contract-type', 
           array('fields'=>'ids')); 
$property_id = get_post_meta(get_the_ID(),'imic_property_site_id',true); 
$property_area_location = wp_get_object_terms(get_the_ID(), 'city-type'); 
$sl = ''; 
$total_area_location = count($property_area_location); 
$num = 1; 
foreach($property_area_location as $sa) { 
    $conc = ($num!=$total_area_location)?'->':''; 
    $sl .= $sa->name.$conc; $num++; 
} 
// We get Longitude & Latitude By Property Address 
$property_longitude_and_latitude=get_post_meta(get_the_ID(),'imic_lat_long',true); 
if(!empty($property_longitude_and_latitude)){ 
    $property_longitude_and_latitude = explode(',', 
    $property_longitude_and_latitude); 
}else{ 
    $property_longitude_and_latitude=getLongitudeLatitudeByAddress($property_address); 
} 
global $imic_options; 
$currency_symbol = imic_get_currency_symbol($imic_options['currency-select']); 
$src = wp_get_attachment_image_src(get_post_thumbnail_id(),'150-100-size'); 
if(!empty($src)): 
    $image_container= '<span class ="property_image_map">'.$src[0].'</span>'; 
else: 
    $image_container=''; 
endif; 
if(!empty($contract)) { 
    $term = get_term($contract[0], 'property-contract-type'); $property_term_type = $term->name; 
} 
if($design_type=='listing') { 
?> 
+4

您是否考虑聘请程序员? – melpomene

+0

我有一个程序员为我建立了这个,但他现在不可用。我只是想对代码进行快速编辑以修复我们的实时网站。我很感激帮助,我明白这可能是一个非常简单的问题。 – Rob

+1

激发你的程序员。 – trincot

我希望这是你的过滤系统的核心(显著重新格式化为可读性 - 让开发者来解决这个问题,请):

query_posts(
    array(
     'post_type' => 'property', 
     'post_status' => 'publish', 
     'paged' => $paged, 
     'author' => $agent, 
     'property-contract-type' => 'southern-oregon' 
    ) 
); 

在猜测,尝试用数组替换'southern-oregon',因此:

['southern-oregon', 'medford-office', ] 

I会猜测这会做一个IN,这本质上是一个OR

+1

这样做的窍门,我重新格式化的代码,并添加数组,现在它正常工作。 – Rob