不能重复使用特色图片?
问题描述:
好的我正在为主/主页上的每个帖子使用精选图像(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 -->
答
更改
<span class="the-thumbnail">
<a href="<?php the_permalink(); ?>">
<img src="<?php echo $img; ?>" />
</a>
</span>
到
<span class="the-thumbnail">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(); ?>
</a>
</span>
我很愿意告诉你你有多棒,不幸的是你的建议没有解决问题。即便如此,我并不怀疑你的整体感觉并欢迎任何其他想法。 – Watts 2012-02-17 21:21:09