如果使用静态首页,则贴子页的ID为get_option(\'page_for_posts\')
.
尝试并替换此部分:
<?php
/*
* The header image.
* Check if this is a post or page, if it has a thumbnail, and if it\'s a big one
*/
if ( is_singular() && has_post_thumbnail( $post->ID ) &&
( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) &&
$image[1] >= $header_image_width ) :
// Houston, we have a new header image!
echo get_the_post_thumbnail( $post->ID, \'post-thumbnail\' );
比如:
<?php //edited to show the selected featured image if a static page is selected as posts page
// The header image
// Check if this is a post or page, if it has a thumbnail, and if it\'s a big one
if( is_singular() ) $post_id = $post->ID;
elseif ( is_home() && get_option(\'page_for_posts\') ) $post_id = get_option(\'page_for_posts\');
if ( ( is_singular() || is_home() && get_option(\'page_for_posts\') ) &&
has_post_thumbnail( $post_id ) &&
( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), array( $header_image_width, $header_image_width ) ) ) &&
$image[1] >= $header_image_width ) :
// Houston, we have a new header image!
echo get_the_post_thumbnail( $post_id, \'post-thumbnail\' );
(wp3.7.1中未测试)
但是我在最近的新闻页面上的任何内容都没有显示出来;它唯一显示的内容是帖子摘要
这就是posts页面与静态首页一起设置时的工作方式,因为它使用索引模板-http://codex.wordpress.org/Creating_a_Static_Front_Page