Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I use the following code to show the post thumbnail (only):

    <?php // Create and run custom loop
        $custom_posts = new WP_Query();
        $custom_posts->query('post_type=page_content&sections=ThemeCL');
        while ($custom_posts->have_posts()) : $custom_posts->the_post();
    ?>
        <div class="float-left">
            <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail(); ?></a>
        </div>
    <?php endwhile; ?>

But for some reason the title and content of the post is being shown (inside

tags!):

        <div class="block-2 border-top">
        <h2><a href="http://localhost/wpac/?blocks=mainbar-2" title="Permalink to Mainbar" rel="bookmark">Mainbar</a></h2>

                    <div class="float-left">

                <a href="http://localhost/wpac/?blocks=mainbar" title="Permalink to Mainbar Left" rel="bookmark"><img width="160" height="150" src="http://localhost/wpac/wp-content/uploads/2011/02/showcase2.png" class="attachment-post-thumbnail wp-post-image" alt="showcase2" title="showcase2" /></a>
                <p><p>Hello this is the title Hello this is the post content</p>
</p>
            </div>

I only want the post thumbnail (Featured Image) to be shown.

Any suggestions?

share|improve this question
    
the_post_thumbnail() should not do this on its own. Do you have extra plugins enabled that could hook into it and add this stuff? –  Jan Fabry Feb 8 '11 at 10:12
    
try using the_title() fn instead –  kaiser Feb 8 '11 at 14:13
add comment

1 Answer

up vote 0 down vote accepted

Something like:

<?php
//Get the Thumbnail URL
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 720,405 ), false, '' );
echo $src[0];
?>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.