我的网站标题中出现Taxonomy.php错误

时间:2014-03-01 作者:MARS

它引用了分类法的第231行。php文件(请参见图)以及该行上的所有内容:

 * Checks that the taxonomy name exists.
 *
 * Formerly is_taxonomy(), introduced in 2.3.0.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 3.0.0
 *
 * @uses $wp_taxonomies
 *
 * @param string $taxonomy Name of taxonomy object
 * @return bool Whether the taxonomy exists.
 */
function taxonomy_exists( $taxonomy ) {
    global $wp_taxonomies;
    return isset( $wp_taxonomies[(string)$taxonomy] );
}
它位于列出社区的常规页面上。我正在使用ACF插件,但以前从未遇到过此错误。

任何想法都会很有帮助。谢谢

enter image description here

更新的代码-----

以下是我在内部标头中使用的代码,这恰好是此特定标头的情况:

<!DOCTYPE html>

  <html>

    <head>

      <title>

        <?php

      echo wp_title();


          bloginfo( \'name\' );

        ?>

      </title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta name="robots" content="index, nofollow" />
      <?php wp_head(); ?>
    </head>

    <body>

      <div class="container-hdr-neighborhoods">

        <header class="col-hdr-internal">

           <a class="logo" href="<?php ( \'home\' ) ?>" alt="Return Home" title="Return Home"></a>

          <nav role="navigation">

            <?php

              $args = array(
                \'menu\' => \'main-menu\'
                );

              wp_nav_menu( $args );

            ?>

          </nav>

          <h1 class="test1"><?php wp_title($echo); ?></h1>

  </header>

</div>
<!--/container-hdr-home-->
这是页面主体部分的代码,我所做的就是使用查询从自定义帖子类型中获取所有永久链接,并在UL中创建一个LI以列出所有邻居。

<?php

/*

  Template Name: Neighborhoods Main Page

*/

get_header( \'internal\' );?>

<div class="container-space"></div>

<div class="container-main">

<?php

  $args = array(
    \'post_type\' => \'neighborhood\'
  );

  $the_query = new WP_Query( $args );

?>

  <ol class="col-neigh-title neighborhood">

  <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

    <li><a href="<?php the_permalink(); ?>"><?php the_field( \'neighborhood_name\' ); ?></a></li>

  <?php endwhile; else: ?>

  </ol>

  <p>There are no posts or pages here.</p>

<?php endif; ?>

</div>

<?php get_footer(); ?>
更新日期:2014年3月22日-------

下面是我的函数的一个片段。启用自定义菜单的php文件:

//Enable custom menus
add_theme_support( \'menus\' );

//Register Navigations
add_action( \'init\', \'my_custom_menus\' );
function my_custom_menus() {
    register_nav_menus(
        array(
            \'primary-menu\' => __( \'Primary Menu\' ),
            \'neighborhood-menu\' => __( \'Neighborhood Menu\' ),
            \'place-menu\' => __( \'Place Menu\' )
        )
    );
}
整个功能。PHP文件-------

<?php

// Load the Theme CSS

function theme_styles() {

  wp_enqueue_style( \'normalize\', get_template_directory_uri() . \'/css/normalize.min.css\' );
  wp_enqueue_style( \'bootstrap\', get_template_directory_uri() . \'/css/bootstrap.min.css\' );
  wp_enqueue_style( \'googlefonts\', \'http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz\');
  wp_enqueue_style( \'googlefonts2\', \'http://fonts.googleapis.com/css?family=Open+Sans\');
  wp_enqueue_style( \'googlefonts3\', \'http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300\');
  wp_enqueue_style( \'main\', get_template_directory_uri() . \'/style.css\' );
  wp_enqueue_style( \'iconset\', get_template_directory_uri() . \'/css/mfglabs_iconset.css\' );
  wp_enqueue_style( \'icon_fonts\', get_template_directory_uri() . \'/css/font/\' );

  wp_register_style( \'flexslider\', get_template_directory_uri() . \'/css/flexslider.css\' );
  if( is_page( \'home\' ) ) {
      wp_enqueue_style( \'flexslider\' );
  }

}

// Load the Theme JS

function theme_js() {

  wp_register_script( \'flexslider\', get_template_directory_uri() . \'/js/flexslider.js\', array(\'jquery\'), \'\', true );
  if( is_page( \'home\' ) ) {
      wp_enqueue_script( \'flexslider\' );
  }
  wp_enqueue_script( \'theme_js\', get_template_directory_uri() . \'/js/theme.js\', array(\'jquery\'), \'\', true );
  wp_enqueue_script( \'theme_js\', get_template_directory_uri() . \'/js/bootstrap.min.js\', array(\'jquery\'), \'\', true );

}

add_action( \'wp_enqueue_scripts\', \'theme_js\' );

add_action( \'wp_enqueue_scripts\', \'theme_styles\' );

//Enable custom menus
add_theme_support( \'menus\' );

//Register Navigations
add_action( \'init\', \'my_custom_menus\' );
function my_custom_menus() {
    register_nav_menus(
        array(
            \'primary-menu\' => __( \'Primary Menu\' ),
            \'neighborhood-menu\' => __( \'Neighborhood Menu\' ),
            \'place-menu\' => __( \'Place Menu\' )
        )
    );
}

// Widget Function
function create_widget( $name, $id, $description ) {

    $args = array(
      \'name\'          => __( $name ),
      \'id\'            => $id,
      \'description\'   => $description,
      \'before_widget\' => \'<li id="%1$s" class="widget %2$s">\',
      \'after_widget\'  => \'</li>\',
      \'before_title\'  => \'\',
      \'after_title\'   => \'\'
    );

    register_sidebar( $args );
}

create_widget( \'First Icon\', \'first_icon\', \'Displays as the first icon\' );
create_widget( \'Second Icon\', \'second_icon\', \'Displays as the second icon\' );
create_widget( \'Third Icon\', \'third_icon\', \'Displays as the third icon\' );
create_widget( \'Fourth Icon\', \'fourth_icon\', \'Displays as the fourth icon\' );

// Background Color


function color_header_bg() {
    global $post;
    // set this to the handle of one of your stylesheets
    $handle = \'/css/style.css\';
    // set this to the meta key you\'ve used
    $meta_key = \'background_color\';
    $bg_color = get_post_meta( $post->ID, $meta_key, $single = true );
    $css = "header { background-color: $bg_color; }";
    wp_add_inline_style( $handle, $css );
}

add_action(  \'wp_enqueue_scripts\', \'color_header_bg\' );

// // Added Parent meta box in Places custom post type, created parent/child relationship neighborhood and places
// add_action( \'add_meta_boxes_place\', \'my_add_meta_boxes\' );

// function my_add_meta_boxes( $post ) {

//   add_meta_box(
//     \'place-parent\',
//     __( \'Parent\', \'example\' ),
//     \'my_parent_meta_box\',
//     $post->post_type,
//     \'side\',
//     \'core\'
//   );
// }

// function my_parent_meta_box( $post ) {

//   $parents = get_posts( array( \'post_type\' => \'neighborhood\', \'numberposts\' => -1 ) );

//   if ( !empty( $parents ) ) {

//     echo \'<select name="parent_id">\';

//     foreach ( $parents as $parent ) {
//       printf( \'<option value="%s"%s>%s</option>\', esc_attr( $parent->ID ), selected( $parent->ID, $post->post_parent, false ), esc_html( $parent->post_title ) );
//     }

//     echo \'</select>\';
//   }
// }
function when_rewrite_rules( $wp_rewrite ) {
  $newrules = array();

  $new_rules[\'place/(.*)/(.*)$\'] = \'index.php?place=$matches[2]\';
    $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
    //echo \'<pre>\'; print_r($wp_rewrite->rules);die;
}
add_filter(\'generate_rewrite_rules\',\'when_rewrite_rules\');
?>
enter image description here

1 个回复
SO网友:s_ha_dum

问题是主题或插件代码,而不是核心代码。有人错误地使用了该函数。例如,这:

taxonomy_exists(array());
。。。生成Warning 这应该看起来很熟悉:

警告:isset中的偏移量类型非法,或/path/to/wordpress/wp includes/taxonomy中的偏移量类型为空。php在线231

所以,在某个地方,某个东西向该函数传递了一个错误的参数——可能是头中的某个东西,或者是挂接到头中执行的挂钩上的某个东西。没有更多的代码,这是我能做的最好的了。

结束

相关推荐

Gravity prerender taxonomy

我试图在重力表单中预填充一个类别字段或发布下拉列表。以下是我所拥有的:<?php add_filter(\"gform_pre_render\", \"gform_prepopluate_populate_books\"); //Note: when changing drop down values, we also need to use the gform_admin_pre_render so that the right values are displ