0

如何将帖子的特色图片链接到类别页面上的全尺寸版本?

这是我的 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; ?> 

任何帮助,将不胜感激!

4

1 回答 1

3

要将帖子缩略图链接到完整大小的版本,您应该能够使用以下内容:

<?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

希望有帮助!

于 2013-02-19T05:21:14.923 回答