2011-04-22 41 views
1

我最近將兩個網站的Wordpress網絡從本地MAMP服務器遷移到了在線網站。除了Post-Thumbnail的功能之外,所有內容都完美地遷移。元框不會出現在任何網站中,也不會出現在整個網絡的任何主題中。文章縮略圖Metabox不會在Wordpress Network上出現

我已經測試了幾個不同的主題,啓用後縮略圖,結果是一樣的。沒有metabox是可見的!我很難過,有沒有人有建議?

的網站之一的functions.php文件是:

if(function_exists('add_theme_support')) { 
    add_theme_support('post-thumbnails', array('page', 'post', 'portfolio')); 

    /** Register custom size */ 
    add_image_size('page-image', 620, 620, false); 
    add_image_size('portfolio-image', 795, 575, true); 
    add_image_size('portfolio-thumbnail', 135, 94, true); 
} 



//------enable post thumbnail preview for custom columns 
if (!function_exists('fb_AddThumbColumn') && function_exists('add_theme_support')) { 

    // for post and investments 

    function fb_AddThumbColumn($cols) { 
     $cols['thumbnail'] = __('Thumbnail'); 
     return $cols; 
    } 

    function fb_AddThumbValue($column_name, $post_id) { 

      $width = (int) 200; 
      $height = (int) 125; 


      if ('thumbnail' == $column_name) { 
       // thumbnail of WP 2.9 
       $thumbnail_id = get_post_meta($post_id, '_thumbnail_id', true); 
       // image from gallery 
       $attachments = get_children(array('post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image')); 
       if ($thumbnail_id) 
        $thumb = wp_get_attachment_image($thumbnail_id, array($width, $height), true); 
       elseif ($attachments) { 
        foreach ($attachments as $attachment_id => $attachment) { 
         $thumb = wp_get_attachment_image($attachment_id, array($width, $height), true); 
        } 
       } 
        if (isset($thumb) && $thumb) { 
         echo $thumb; 
        } else { 
         echo __('None'); 
        } 
      } 
    } 

    // for posts 
    add_filter('manage_posts_columns', 'fb_AddThumbColumn'); 
    add_action('manage_posts_custom_column', 'fb_AddThumbValue', 10, 2); 

    // for portfolio 
    add_filter('manage_portfolio_columns', 'fb_AddThumbColumn'); 
    add_action('manage_portfolio_custom_column', 'fb_AddThumbValue', 10, 2); 
} 
*/ 

function the_post_thumbnail_url($post_id) { 
    echo wp_get_attachment_url(get_post_thumbnail_id($post_id)); 
} 
+0

任何想法如何在WP 3.5.1中做到這一點? 我的全部問題:http://stackoverflow.com/questions/16932529/post-thumbnail-metabox-doesnt-appear-on-customposttype-from-childtheme – lippoliv 2013-06-06 10:11:30

回答

1

您必須切換到Network Admin模式

然後去

Settings>Network settings

接近尾聲,你會發現

Upload Settings>Media upload buttons

我檢查Images到請參閱Featured Image框出現在我的新帖子管理頁面。

+1

完全就是這樣。謝謝! – Erin 2012-03-27 04:06:33

1

我曾與縮略圖類似的問題,當我遷移的WordPress的網絡。 我已經使用此代碼修復了它,也許它可以幫助你。您需要添加該代碼添加到functions.php

<?php 
function get_timthumb_thumbnail($post_id = null) { 
    global $blog_id; 

    //we can access it, so why not use it? 
    $is_mu = WP_ALLOW_MULTISITE; 

    //if is true it means it's a wordpress MU site and we'll have to do some work 
    if($is_mu == true): 
     $thumbnail_id=get_the_post_thumbnail($post_id); 
     preg_match ('/src="(.*)" class/',$thumbnail_id,$link); 
     $imageParts = explode('files/', $link[1]); 
     if (!empty($imageParts[1])): 
      //check if the image is in the blog directory 
      if(@getimagesize('./wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1])): 

       $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/blogs.dir/' . $blog_id . '/files/' . $imageParts[1]; 

      endif; 
      //check if the image is in the main uploads directory (you never know) 
      if(@getimagesize('./wp-content/uploads/' . $imageParts[1])): 

       $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/uploads/' . $imageParts[1]; 

      endif; 
        else: 
          $imageParts = explode('uploads/', $link[1]); 
          if(@getimagesize('./wp-content/uploads/' . $imageParts[1])): 
           $thumbnail = 'http://'.$_SERVER['HTTP_HOST'].'/wp-content/uploads/' . $imageParts[1]; 
          endif; 
     endif; 

    else: 
     $thumbnail_id=get_the_post_thumbnail($post_id); 
      preg_match ('/src="(.*)" class/',$thumbnail_id,$link); 
      $thumbnail = $link[1]; 
    endif; 

    return $thumbnail; 
} 
?> 

要在循環使用此功能,我又增加了這樣的事情:

<?php $thumb = get_timthumb_thumbnail($post->ID); ?> 
<?php if(has_post_thumbnail()){ ?> 
    <img src="<?php echo $thumb;?>" class="thumb" /> 
<?php }else{ 
    echo '<img src="'.get_bloginfo("template_url").'/img/boyds.png" class="thumbdflt" />'; 
}?> 

問候。

+0

感謝您的建議!但是,它看起來像這個函數着重於在循環中獲取圖像。縮略圖在我的主題中顯示得很好,但在查看管理員端時不會顯示。 – Erin 2011-04-24 00:29:14

相關問題