[英]Wordpress Template - “Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string”
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: 我使用的是最新版本的Wordpress,并且在撰写新文章时,出现以下错误,而不是书写区域下方的可选框:
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 可捕获的致命错误:__PHP_Incomplete_Class类的对象无法在第466行的/home/xxx/public_html/wp-content/themes/xxx/functions/meta-boxes.php中转换为字符串
I've pasted a the problem code below taken from meta-boxes.php 我粘贴了以下来自meta-boxes.php的问题代码
Also, below, i've commented on the 466th line of code to let you know where the point if error is: 另外,在下面,我对代码的第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
I think $meta->name is object. 我认为$ meta-> name是对象。 try : print_r( $meta->name ). 尝试:的print_r($荟萃>名称)。
OR 要么
I think it should be: $metaName = $meta->labels->name 我认为应该是:$ metaName = $ meta-> labels-> name
Not tested though. 虽然没有测试。
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.