如何将帖子的精选图片链接到类别页面上的完整尺寸版本?
这是我在category.php上的循环:
<h1>Professional Portfolio Gallery - <?php single_cat_title(); ?></h1>
<p><?php echo category_description(); ?></p>
<?php if (have_posts()) : ?>
<ul class="portfolio">
<?php while (have_posts()) : the_post(); ?>
<li>
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
?>
<?php the_excerpt(); ?></li>
<?php endwhile; ?>
</ul>
<?php wp_paging(); ?>
<?php else : ?>
<h1>Not Found</h1>
<p><?php _e("Sorry, but you are looking for something that isn't here."); ?></p>
<?php endif; ?>
任何帮助将不胜感激!
答案 0 :(得分:2)
要将Post Thumbnails链接到完整尺寸版本,您应该能够使用以下内容:
<?php
if ( has_post_thumbnail()) {
$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');
echo '<a href="' . $full_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" >';
the_post_thumbnail('thumbnail');
echo '</a>';
}
?>
您可以在此处找到有关此重定向的更多信息:http://codex.wordpress.org/Function_Reference/the_post_thumbnail
希望有所帮助!