0
好的我正在爲主/主頁上的每個帖子使用精選圖像(F圖像)。它適用於絕大多數情況,但對於包含視頻的帖子,我想每次重複使用相同的F圖像。不能重複使用特色圖片?
由於某種原因,F圖像在第一次上傳時會正常工作,但是當我嘗試在另一篇文章中重複使用相同的圖像時,它應該出現在主頁上的空白爲空,即使沒有報告錯誤。我試着通過url進行鏈接,並通過從媒體管理頁面選擇所需的圖像。
它工作的唯一方法是上傳完全相同圖像的全新實例。這是無稽之談。必須有某種方式來重用圖像,而無需重新上傳每個需要使用它的文章。我想到我的服務器上存在54個相同圖像的實例,我感到噁心。是什麼賦予了?我只是沒有顏色,忽略了相關的PHP代碼?感謝您的所有輸入!
這裏是PHP函數的代碼:
<?php
// Make theme available for translation
// Translations can be filed in the /languages/ directory
load_theme_textdomain('your-theme', TEMPLATEPATH . '/languages');
$locale = get_locale();
$locale_file = TEMPLATEPATH . "/languages/$locale.php";
if (is_readable($locale_file))
require_once($locale_file);
// Get the page number
function get_page_number() {
if (get_query_var('paged')) {
print ' | ' . __('Page ' , 'your-theme') . get_query_var('paged');
}
} // end get_page_number
// Enable post thumbnails
add_theme_support('post-thumbnails');
set_post_thumbnail_size(300, 200, true);
?>
這裏是它是如何被稱爲在index.php:
<!-- get the thumbnail -->
<?php
//Get images attached to the post
$img = null;
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'numberposts' => -1,
'order' => 'ASC',
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
$img = wp_get_attachment_thumb_url($attachment->ID);
break;
} ?>
<!-- ***** THE ACTUAL IMAGE ***** -->
<span class="the-thumbnail">
<a href="<?php the_permalink(); ?>">
<img src="<?php echo $img; ?>" />
</a>
</span>
<!-- ***** END THE ACTUAL IMAGE ***** -->
<?php }
?>
<!-- end get the thumbnail -->
我很願意告訴你你有多棒,不幸的是你的建議沒有解決問題。即便如此,我並不懷疑你的整體感覺並歡迎任何其他想法。 – Watts 2012-02-17 21:21:09