0
我正在使用最新版本的Wordpress,並在編寫新帖子時,出現以下錯誤而不是可選盒,位於書寫區域下面:Wordpress模板 - 「可捕捉的致命錯誤:類__PHP_Incomplete_Class的對象無法轉換爲字符串」
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
我貼一個問題下面的代碼從元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