【问题标题】:Wordpress Template - "Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string"Wordpress 模板 - “可捕获的致命错误:__PHP_Incomplete_Class 类的对象无法转换为字符串”
【发布时间】:2012-11-07 06:06:00
【问题描述】:

我正在使用最新版本的 Wordpress,在撰写新文章时,我收到以下错误,而不是位于写作区域下方的可选框:

可捕获的致命错误:__PHP_Incomplete_Class 类的对象可能 不被转换成字符串 /home/xxx/public_html/wp-content/themes/xxx/functions/meta-boxes.php 第 466 行

我粘贴了下面的问题代码,取自 meta-boxes.php

此外,我在下面的第 466 行代码中进行了注释,让您知道错误所在:

 <?php  
    // get review-specific meta fields
    global $oswcPostTypes; 
    $postTypeId = get_post_type( $post->ID );   
    $postType = $oswcPostTypes->get_type_by_id($postTypeId);
    $meta_fields = $postType->meta_fields;
    foreach($meta_fields as $meta){
        //make backwards compatible
        if(is_object($meta)){
            $metaName = $meta->name;
        }else{
            $metaName = $meta;
        }
        $metaNameSafe = str_replace(" ","_",$metaName); // **466th line of error**
        $theMeta = get_post_meta($post->ID, $metaName, $single = true); ?>      
        <p>
        <label for="<?php echo $metaNameSafe; ?>"><?php echo $metaName; ?></label> </td>
        <textarea class="widefat" id="<?php echo $metaNameSafe; ?>" name="<?php echo $metaNameSafe; ?>"><?php echo $theMeta; ?></textarea>
        </p>

    <?php 

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    我认为 $meta->name 是对象。试试:print_r($meta->name)。

    我认为应该是: $metaName = $meta->标签->名称

    虽然没有测试。

    谢谢

    【讨论】:

      猜你喜欢
      • 2014-02-21
      • 1970-01-01
      • 2015-09-21
      • 1970-01-01
      • 2015-03-08
      • 2013-08-07
      • 1970-01-01
      • 2018-03-12
      • 1970-01-01
      相关资源
      最近更新 更多