投稿・固定ページのアイキャッチ画像を非表示にしたいと思いサイトで調べると、「sigle.phpのthumbnailの部分を削除又は非表示にする」との情報を得たので早速チェック、ところがthumbnailの記述がなかったので、他のphpを調べてみると「header.php」の中程に記述されてたので「//」で非表示、しかし投稿記事の上部にアイキャッチ画像が表示される。投稿ページ上なので「postフォルダーにあるcontent.php」をチェックするとアイキャッチ画像の部分があったので「<!-- ーー>」で囲って試したところ、今度は間違いなく非表示できた。
1] header.php
1 2 3 4 5 |
//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(), 'twentyseventeen-featured-image' ); //echo '</div><!-- .single-featured-image-header -->'; //endif; |
2] template-parts/post/content.php
1 2 3 4 5 6 7 |
<!-- <?php if ( '' !== get_the_post_thumbnail() && ! is_single() ) : ?> --> <!-- <div class="post-thumbnail"> <a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail( 'twentyseventeen-featured-image' ); ?> </a> </div> --><!-- .post-thumbnail --> <!-- <?php endif; ?> --> |
アイキャッチ画像の記述がどこにあるのか焦ったけど、なんとかアイキャッチ画像を非表示できた。