반응형
_post_thumbnail 폭을 100%로 설정
설정 방법the_post_thumbnail
따라서 크기에 맞게 어레이를 사용하지 않고 100% 폭과 자동 높이로 설정할 수 있습니다.
<?php $ht_featured_img = get_option('ht_featured_img');
if ($ht_featured_img == "true") { ?>
<?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { /* if post has a thumbnail */ ?>
<div class="post-image">
<?php the_post_thumbnail( array(1215,9999) ); ?>
</div><!--post-image-->
<?php } ?>
<?php } ?>
<?php $ht_featured_img = get_option('ht_featured_img'); if ($ht_featured_img == "true") { ?>
<?php if ( ( function_exists('has_post_thumbnail') ) && ( has_post_thumbnail() ) ) {
$post_thumbnail_id = get_post_thumbnail_id();
$post_thumbnail_url = wp_get_attachment_url( $post_thumbnail_id );
?>
<div class="post-image">
<img title="image title" alt="thumb image" class="wp-post-image" src="<?php echo $post_thumbnail_url; ?>" style="width:100%; height:auto;">
</div>
<?php } ?>
<?php } ?>
<? if( has_post_thumbnail( $post_id ) ): ?>
<div class="post-image">
<img title="image title" alt="thumb image" class="wp-post-image"
src="<?=wp_get_attachment_url( get_post_thumbnail_id() ); ?>" style="width:100%; height:auto;">
</div>
<? endif; ?>
또 다른 방법은
<img src="<?php echo get_the_post_thumbnail_url (); ?>" style="width:100%; height:auto;">
언급URL : https://stackoverflow.com/questions/18906199/setting-the-post-thumbnail-width-to-100
반응형
'programing' 카테고리의 다른 글
React TypeScript HoC - 컴포넌트를 프로펠러로 전달 (0) | 2023.04.02 |
---|---|
jQuery를 사용하여 JSON 개체에 키가 있는지 확인합니다. (0) | 2023.04.02 |
이 각도 개선소켓과 함께 사용하는 JS 공장.이오 (0) | 2023.04.02 |
모바일 버전에 대해 다른 정적 홈페이지를 설정하는 방법(WordPress) (0) | 2023.04.02 |
WordPress에서 프로그래밍 방식으로 섬네일이 있는 게시물 추가 (0) | 2023.04.02 |