已搬移至新博客:http://blog.guaidm.com
欢迎光临
首先找到主题目录下的:functions.php文件,为其添加代码如下:
1 2 3 4
| //使WordPress支持post thumbnail if (function_exists('add_theme_support' )) { add_theme_support( 'post-thumbnails' ); } |
注意:代码是添加在body中,不是函数里,如果不清楚就查找第一个,添加在它的下面就行了
1
| <?php |
然后打开主题目录下的文章首页文件,例如index.php,添加如下代码到the_content之前,也就是文章内容之前
1 2 3 4 5
| <?php if ( has_post_thumbnail() ) : ?> <a href="<?php the_permalink();?>"> <?php the_post_thumbnail( array( 100,100 ), array( 'class' => 'alignleft' ) ); ?> </a> <?php endif;?> |
这样就可以在后台文章页面、相册页面等看到特色图像的添加按钮,并在首页显示了,上段代码100,100是图像的尺寸,alignleft是居左显示方式,可自行修改。
如果你还在使用老版本的wordpress,可以试试插件 [featured image]