簡體   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