向PHP查询添加多个选项
我有一个财产清单网站,我需要帮助的代码,过滤搜索结果。以下代码包括合同类型为southern oregon的所有房地产。我希望它也包括合同类型=到medford办公室。有人能告诉我如何将其添加到代码中吗 代码如下:向PHP查询添加多个选项,php,wordpress,Php,Wordpress,我有一个财产清单网站,我需要帮助的代码,过滤搜索结果。以下代码包括合同类型为southern oregon的所有房地产。我希望它也包括合同类型=到medford办公室。有人能告诉我如何将其添加到代码中吗 代码如下: <?php echo $div; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array('post_type'=>'property','post_status
<?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') {
?>
我希望这是您的过滤系统的核心,为了可读性,对其进行了显著的重新格式化-请让您的开发人员修复此问题:
query_posts(
array(
'post_type' => 'property',
'post_status' => 'publish',
'paged' => $paged,
'author' => $agent,
'property-contract-type' => 'southern-oregon'
)
);
猜测一下,尝试用数组替换“southern oregon”,因此:
['southern-oregon', 'medford-office', ]
我想这会做一个IN,本质上是一个OR。你考虑过雇佣一个程序员吗?我有一个程序员为我做这个,但他现在不在。我只是想做一个快速编辑的代码,以修复我们的现场网站。感谢您的帮助,我知道这可能是一个非常简单的问题。解雇您的程序员。我假设在代码示例的第4行中,我需要向“property contract type”=>“southern-oregon”添加额外变量。啊,通过从互联网复制/粘贴代码在生产中开发。可能会出什么问题…这就解决了问题,我重新格式化了代码并添加了数组,现在它可以正常工作了。