Wordpress 模板 - “可捕获的致命错误:__PHP_Incomplete_Class 类的对象无法转换为字符串" [英] Wordpress Template - "Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string"
问题描述
我使用的是最新版本的 Wordpress,在撰写新帖子时,我在位于写作区域下方的可选框位置出现以下错误:
I'm using the latest version of Wordpress and while writing a new post, i'm getting a following error in place of the optional boxes, located below the writing area:
可捕获的致命错误:__PHP_Incomplete_Class 类的对象可以不会被转换成字符串/home/xxx/public_html/wp-content/themes/xxx/functions/meta-boxes.php在线 466
Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string in /home/xxx/public_html/wp-content/themes/xxx/functions/meta-boxes.php on line 466
我粘贴了以下取自 meta-boxes.php 的问题代码
I've pasted a the problem code below taken from meta-boxes.php
另外,在下面,我对第 466 行代码进行了评论,让您知道错误的关键在哪里:
Also, below, i've commented on the 466th line of code to let you know where the point if error is:
<?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( $meta->name ).
I think $meta->name is object. try : print_r( $meta->name ).
或
我认为应该是:$metaName = $meta->labels->name
I think it should be: $metaName = $meta->labels->name
虽然没有测试.
谢谢
这篇关于Wordpress 模板 - “可捕获的致命错误:__PHP_Incomplete_Class 类的对象无法转换为字符串"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!