Php 是否将自定义字段添加到搜索数组?
我正在为我的wordpress网站使用一个特定的主题,它已经创建了自己的搜索小部件。这个小部件允许我进行txt搜索和分类搜索。然而,我真的很想添加一个额外的搜索下拉列表,用于填充某个自定义字段中的值,称为“type” 所以要明确的是,在WP中,我有一个自定义的帖子类型。此自定义帖子类型中的帖子通过自定义分类法进行分类。现在我有了一个搜索小部件,它允许我在txt+自定义分类法上,通过自定义帖子类型中的帖子进行搜索。不过,我还创建了一个自定义字段“type”,它为(自定义)帖子指定“asquid”或“offered”。我想用这个自定义字段“type”填充当前搜索小部件中的下拉列表,以便人们可以选择某个帖子的“type”来执行搜索 我希望我的要求是明确的,如果我的英语有时不好,对不起(尽我所能:) 我的搜索小部件代码如下所示:Php 是否将自定义字段添加到搜索数组?,php,wordpress,search,custom-fields,Php,Wordpress,Search,Custom Fields,我正在为我的wordpress网站使用一个特定的主题,它已经创建了自己的搜索小部件。这个小部件允许我进行txt搜索和分类搜索。然而,我真的很想添加一个额外的搜索下拉列表,用于填充某个自定义字段中的值,称为“type” 所以要明确的是,在WP中,我有一个自定义的帖子类型。此自定义帖子类型中的帖子通过自定义分类法进行分类。现在我有了一个搜索小部件,它允许我在txt+自定义分类法上,通过自定义帖子类型中的帖子进行搜索。不过,我还创建了一个自定义字段“type”,它为(自定义)帖子指定“asquid”或
// widget to show the search widget
function cp_ad_search_widget() {
global $cp_options;
$args = array(
'show_option_all' => __( 'All Categories', APP_TD ),
'hierarchical' => $cp_options->cat_hierarchy,
'hide_empty' => $cp_options->cat_hide_empty,
'depth' => $cp_options->search_depth,
'show_count' => $cp_options->cat_count,
'pad_counts' => $cp_options->cat_count,
'orderby' => 'name',
'title_li' => '',
'use_desc_for_title' => 1,
'name' => 'scat',
'selected' => cp_get_search_catid(),
'taxonomy' => APP_TAX_CAT,
);
$args = apply_filters( 'cp_dropdown_search_widget_args', $args );
?>
<div class="recordfromblog">
<form action="<?php echo home_url( '/' ); ?>" method="get" id="searchform" class="form_search">
<input name="s" type="text" id="s" class="editbox_search" <?php if(get_search_query()) { echo 'value="'.trim(strip_tags(esc_attr(get_search_query()))).'"'; } else { ?> value="<?php _e( 'What are you looking for?', APP_TD ); ?>" onfocus="if (this.value == '<?php _e( 'What are you looking for?', APP_TD ); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'What are you looking for?', APP_TD ); ?>';}" <?php } ?> />
<?php wp_dropdown_categories( $args ); ?>
<div class="pad5"></div>
<input type="submit" class="btn_orange" value="<?php _e( 'Search', APP_TD ); ?>" title="<?php _e( 'Search', APP_TD ); ?>" id="go" name="sa" />
</form>
</div><!-- /recordfromblog -->
<?php
}
?>
//显示搜索小部件的小部件
函数cp_ad_search_widget(){
全球$cp_选项;
$args=数组(
“显示所有选项”=>(“所有类别”,应用程序),
“层次结构”=>$cp\U选项->类别层次结构,
'hide_empty'=>$cp_选项->cat_hide_empty,
“深度”=>$cp\u选项->搜索深度,
“显示计数”=>$cp\U选项->类别计数,
“pad_计数”=>$cp_选项->cat_计数,
'orderby'=>'name',
“title_li'=>”,
“将描述用于标题”=>1,
'name'=>'scat',
'选定'=>cp\u get\u search\u catid(),
“分类法”=>APP\U TAX\U CAT,
);
$args=apply_filters('cp_dropdown_search_widget_args',$args);
?>
value=“”onfocus=“if(this.value==”){this.value=”;}”onblur=“if(this.value==”){this.value=”;}”/>