我正在撰写自定义帖子模板。特色图片总是显得很大,占据了整个页面。
<?php
/* Start the Loop */
while ( have_posts() ) :
the_post();
// get_template_part( 'template-parts/post/content', get_post_format() );
the_post_thumbnail();
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
the_post_navigation(
array(
'prev_text' => '<span class="screen-reader-text">' . __( 'Previous Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Previous', 'twentyseventeen' ) . '</span> <span class="nav-title"><span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '</span>%title</span>',
'next_text' => '<span class="screen-reader-text">' . __( 'Next Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Next', 'twentyseventeen' ) . '</span> <span class="nav-title">%title<span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ) . '</span></span>',
)
);
endwhile; // End of the loop.
?>
我想控制特色图片的显示。即使我删除了the_post_thumbnail(),也会显示一个大图像。
输出:
答案 0 :(得分:0)
默认WordPress提供了一些你可以使用的参数。
the_post_thumbnail( 'thumbnail' ); // Thumbnail (150 x 150 hard cropped)
the_post_thumbnail( 'medium' ); // Medium resolution (300 x 300 max height 300px)
the_post_thumbnail( 'medium_large' ); // Medium Large (added in WP 4.4) resolution (768 x 0 infinite height)
the_post_thumbnail( 'large' ); // Large resolution (1024 x 1024 max height 1024px)
the_post_thumbnail( 'full' ); // Full resolution (original size uploaded)
答案 1 :(得分:0)
你需要在get_the_post_thumbnail()中添加大小,因为我用缩略图替换了二十二个特色图像,或者你可以通过数组添加它
get_the_post_thumbnail( get_queried_object_id(), array(150,150); );
get_the_post_thumbnail( get_queried_object_id(), 'thumbnail' );
if ( ( is_single() || ( is_page() && ! twentyseventeen_is_frontpage() ) ) && has_post_thumbnail( get_queried_object_id() ) ) :
echo '<div class="single-featured-image-header">';
echo get_the_post_thumbnail( get_queried_object_id(), 'thumbnail' );
echo '</div><!-- .single-featured-image-header -->';
endif;
肯定会有效。