【发布时间】:2013-07-10 21:31:06
【问题描述】:
您好,我收到了 Wordpress 包含的错误,当我将分类的多个值发布到 index.php 时会出现此错误
<form role="search" method="post" id="searchform" action="<?php echo home_url( '/' ); ?>">
<select name="books[]" multiple>
<option value="a">a</option>
<option value="b">b</option>
</select>
<input type="submit" id="searchsubmit" value="Search" />
</form>
警告:strpos() 期望参数 1 是字符串,数组在 www.domain.com\wordpress\wp-includes\query.php 行 b>1718
警告:preg_split() 期望参数 2 是字符串,数组在 www.domain.com\wordpress\wp-includes\ 中给出第 1719 行上的 query.php
警告:为 www.domain.com\wordpress 中的 foreach() 提供的参数无效\wp-includes\query.php 在 1720
foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) {
if ( 'post_tag' == $taxonomy )
continue; // Handled further down in the $q['tag'] block
if ( $t->query_var && !empty( $q[$t->query_var] ) ) {
$tax_query_defaults = array(
'taxonomy' => $taxonomy,
'field' => 'slug',
);
if ( isset( $t->rewrite['hierarchical'] ) && $t->rewrite['hierarchical'] ) {
$q[$t->query_var] = wp_basename( $q[$t->query_var] );
}
$term = $q[$t->query_var];
if ( strpos($term, '+') !== false ) {
$terms = preg_split( '/[+]+/', $term );
foreach ( $terms as $term ) {
$tax_query[] = array_merge( $tax_query_defaults, array(
'terms' => array( $term )
) );
}
} else {
$tax_query[] = array_merge( $tax_query_defaults, array(
'terms' => preg_split( '/[,]+/', $term )
) );
}
}
}
当我将它发布到 searchresults.php 或当我使用单个值或无分类名称时,不会出现错误;
<select name="books">
<select name="NoneTaxonomyName[]" multiple>
有人知道如何解决这个问题吗?
【问题讨论】:
标签: wordpress search post taxonomy