我想进行自定义搜索
这是http://alessandro.host/?country=Italy&area=Milan&type=luxury-hotels
这就是解释:
post_meta
post_meta
我如何进行自定义搜索?
答案 0 :(得分:2)
我会在WordPress 3.1中查看scribu对高级元数据查询的解释,以帮助您: http://scribu.net/wordpress/advanced-metadata-queries.html
另外,请看一下关于WP_Query的WordPress文档: http://codex.wordpress.org/Function_Reference/WP_Query
在你的情况下,听起来你需要的就是这样:
<?php
$country = $_GET['country'];
$area = $_GET['area'];
$type = $_GET['type'];
query_posts( array(
'category_name' => $type,
'meta_query' => array(
array(
'key' => 'country',
'value' => $country,
),
array(
'key' => 'area',
'value' => $area,
)
)
) );
// now do the loop as normal
?>