这就是我的function.php
里面的内容 <?php
if ( function_exists( 'add_theme_support' )){
add_theme_support( 'post-thumbnails' );
}
if ( function_exists( 'add_image_size' )){
add_image_size('featured', 400, 340, true);
add_image_size('post-thumb', 100, 140, true);
}
?>
这就是我的index.php
里面的内容 <?php the_post_thumbnail('post-thumb'); ?>
Screen Options
的特色图片。Edit Post
问题是缩略图没有显示在index.php(主页)中。我错过了什么吗?非常感谢。
答案 0 :(得分:0)
将上面的代码放在上面:the_content();
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail('post-thumb');
}
?>
有关详情,请参阅此处:http://codex.wordpress.org/Function_Reference/the_post_thumbnail和https://wordpress.stackexchange.com/questions/39798/thumbnail-cropping-with-add-image-size
答案 1 :(得分:0)
替换非工作代码
add_theme_support(‘post-thumbnails’);
有工作变体:
add_theme_support( ‘post-thumbnails’, array( ‘post’, ‘page’, ‘player’ ) );