繁体   English   中英

Wordpress模板-“可捕获的致命错误:类__PHP_Incomplete_Class的对象无法转换为字符串”

[英]Wordpress Template - “Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string”

我使用的是最新版本的Wordpress,并且在撰写新文章时,出现以下错误,而不是书写区域下方的可选框:

可捕获的致命错误:__PHP_Incomplete_Class类的对象无法在第466行的/home/xxx/public_html/wp-content/themes/xxx/functions/meta-boxes.php中转换为字符串

我粘贴了以下来自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 

我认为$ meta-> name是对象。 尝试:的print_r($荟萃>名称)。

要么

我认为应该是:$ metaName = $ meta-> labels-> name

虽然没有测试。

谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM