为什么帖子标题和内容会自动显示在帖子缩略图(精选图片)中?

时间:2011-02-08 作者:janoChen

我使用以下代码显示帖子缩略图(仅限):

    <?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; ?>
但出于某种原因,帖子的标题和内容正在显示(标签内!):

        <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>
我只想显示帖子缩略图(特色图片)。

有什么建议吗?

1 个回复
最合适的回答,由SO网友:stffn 整理而成

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];
?>
结束

相关推荐