我有一个名为“ building”的自定义帖子类型。在此帖子类型的档案库中,我放置了一个搜索表单,其中包含输入搜索和带有以下代码的类别下拉列表。问题是,当我只将关键字放入搜索输入而不选择类别时,我只能从该帖子类型中获得结果(这就是我想要的)。但是,如果我选择一个类别,则可以从所有帖子类型中获得结果。我该如何解决?
<div class="archive-search"><form method="get" id="searchform" action="<?php echo home_url(); ?>/">
<input type="search" class="sb-search-input" placeholder="<?php _e('Search Projects...', 'wpzoom') ?>" name="s" id="s" autocomplete="off" />
<input name="post_type" type="hidden" value="building" />
<?php
// output all of our Categories
// for more information see http://codex.wordpress.org/Function_Reference/wp_dropdown_categories
$swp_cat_dropdown_args = array(
'show_option_all' => __( 'Select Category' ),
'orderby' => 'title',
'order' => 'ASC',
);
wp_dropdown_categories( $swp_cat_dropdown_args );
?> <?php
echo "<br>";
?>
<input type="submit" id="searchsubmit" class="sb-search-submit" value="<?php _e('Search', 'wpzoom') ?>" />
<span class="sb-icon-search"></span>
</form></div>