如何在PHP WordPress中获取缩略图大小?

时间:2018-04-10 07:42:11

标签: php css wordpress

这是我的PHP代码,我想添加大小缩略图max 300x420

<a class="blog-views" href="<?php the_permalink(); ?>"><?php
the_post_thumbnail('full'); ?></a>

我从wordpress获得了这段代码,但是这对我,缩略图,中等,mdeium大,大而且完整没有帮助。

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)

3 个答案:

答案 0 :(得分:1)

您可以使用set_post_thumbnail_size(300,420,true);

有关详情,请点击此链接set_post_thumbnail_size

答案 1 :(得分:1)

尝试使用此代码:

the_post_thumbnail( array(300,420) );

答案 2 :(得分:1)

您可以从管理员方面更改缩略图大小,wp-admin / options-media.php