only display img if there is a img

This commit is contained in:
ed barz 2023-03-27 21:54:14 +02:00
parent fb3eb0c906
commit 8db723182a
1 changed files with 9 additions and 1 deletions

View File

@ -3,7 +3,15 @@
<header>
<h3><?php echo get_the_title(); ?></h3>
<img src="<?php echo get_the_post_thumbnail_url(); ?>" alt="<?php echo get_the_title(); ?>">
<?php
if ( has_post_thumbnail() ) {
?>
<img src="<?php echo get_the_post_thumbnail_url(); ?>" alt="<?php the_title_attribute(); ?>">
<?php
}
?>
</header>