【问题标题】:Error posting data to index.php of wordpress Thema将数据发布到 wordpress Thema 的 index.php 时出错
【发布时间】: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.php1720

    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


    【解决方案1】:

    解决了; query_var => 假

    register_taxonomy('taxname', 'post_type', array('hierarchical' => true, 'label' => 'lable',     'query_var' => false, 'rewrite' => array('slug' => 'slug')));
    

    【讨论】:

      猜你喜欢
      • 2021-05-11
      • 2015-07-16
      • 2011-08-27
      • 2018-11-02
      • 1970-01-01
      • 2020-11-19
      • 2019-07-29
      • 1970-01-01
      • 2023-03-21
      相关资源
      最近更新 更多