treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Detect post thumbnail

  • WP. Simply I use this code to get the post thumbnail: (when the thumbnail.php page provided)
    <?php include(TEMLATEPATH . '/thumbnail.php')' ?>
    It's done for a single page with a single thumbnail. But what to do, when I want to have a gallery of thumbnails or something like that. See the code below:

    <?php
    query_posts('posts_per_page=1&cat=7');
    while(have_posts()) : the_post();?>
    <h1><a href="<?php the_permalink() ?>" ><?php the_title(); ?></a>
    <!-- Here I want to show its thumbnail -->
    <!-- and after that, I have another 'category first post' title with its thumbnail -->

    In the code above, if I use my first code (.../thumbnail.php), that will show same thumbnails for the titles and should use something else than this one. I want to give each title its own thumbnail.
    Note. I want to use my special post thumbnail as its thumbnail, not the first image of the post.
    How to do that without using a plugin or custom fields, with a simple trick?
  • This solved my problem:

    <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
    <?php the_post_thumbnail(); ?>
    </a>
    <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>