我正在使用最新版本的 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