第二个if语句要求它是一篇文章,因此404页无法通过。
我会这样做,使用elseif语句。我还将$缩略图->ID更改为$post->ID,因为前者没有定义。
add_action( \'genesis_before_header\', \'minimum_featured_image\' );
function minimum_featured_image() {
global $post;
if ( is_home() ) {
echo \'<div id="featured-image-home">\';
echo get_the_post_thumbnail($post->ID, \'header\');
echo \'</div>\';
}
elseif ( is_singular( array( \'post\' , \'page\' ) ) && ( !has_post_thumbnail( $post->ID ) ) ){
echo \'<div id="featured-image">\';
echo get_the_post_thumbnail($post->ID, \'header\');
echo \'</div>\';
}
elseif(is_singular( array( \'post\' , \'page\' ) ){
echo \'<div id="featured-image-home"><img src="\'. get_stylesheet_directory_uri() . \'/images/blog-banner.jpg" /></div>\';
}
}