如何在WordPress的帖子中添加缩略图()

我想在首页的帖子中添加缩略图。但是不知道该怎么做。我的主题不支持custom_field。我在这里粘贴了类别代码之一。

< div class="featured"> < h2> HEADLINES< /h2> < !--This is where the thumbnails are found for the homepage bottom section - note the custom field name for this image is "thumbnail". Recommended image size is 70x70, as the stylesheet is written for this size.--> < ?php $recent = new WP_Query("cat=3& showposts=3"); while($recent-> have_posts()) : $recent-> the_post(); ?> < ?php the_post_thumbnail(); ?> < ?php if( get_post_meta($post-> ID, "thumbnail", true) ): ?> < a href="http://www.srcmini.com/< ?php the_post_thumbnail() ?>" rel="bookmark"> < imgstyle="float:left; margin:0px 10px 0px 0px; " src="http://www.srcmini.com/< ?php echo get_post_meta($post-> ID,"thumbnail", true); ?> " alt="alt text" /> < /a> < ?php else: ?> < a href="http://www.srcmini.com/< ?php the_permalink() ?>" rel="bookmark"> < imgstyle="float:left; margin:0px 10px 0px 0px; "src="http://www.srcmini.com/< ?php bloginfo('template_url'); ?> /images/thumbnail.jp" alt="Default thumbnail" /> < /a> < ?php endif; ?> < b> < a href="http://www.srcmini.com/< ?php the_permalink() ?>" > < ?php the_title(); ?> < /a> < /b> < ?php the_content_limit(80, ""); ?> < div style="border-bottom:1px dotted #AFAFAF; margin-bottom:10px; padding:0px 0px 10px 0px; clear:both; "> < /div> < ?php endwhile; ?>

我将扩展名jpg重命名为jp coz stackoverflow, 不允许添加图像。我也变了
#1在WordPress 2.9之前, 缩略图必须是自定义字段。从那时起, 添加了本机支持。
在法典上阅读相关内容:http://codex.wordpress.org/Post_Thumbnails
简而言之, 将其添加到主题的functions.php文件中:
if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); }

然后, 将此添加到你希望缩略图出现的主题:
< ?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it. the_post_thumbnail(); } ?>

#2【如何在WordPress的帖子中添加缩略图()】你可以试试这个。
http://wordpress.org/extend/plugins/wp-post-thumbnail
我没有测试。谢谢

    推荐阅读