Reputation: 1226
I want to display featured image caption in a paragraph only if it exists.
I am trying the following without luck:
<?php if (the_post_thumbnail_caption()) { echo '<p class="wp-caption-text">' . the_post_thumbnail_caption() . echo '</p>' } ?>
and it's resulting in fatal error:
C:\xampp\htdocs\builder\wp-content\themes\BuilderChild-Default\extensions\magazine-enhanced2\functions.php:88:syntax error, unexpected T_ECHO
Please help.
Upvotes: 1
Views: 4883
Reputation: 28015
You have redundant . echo
near '</p>'
. This should be:
<?php
if (the_post_thumbnail_caption()) {
echo '<p class="wp-caption-text">' . the_post_thumbnail_caption() . '</p>';
}
?>
Upvotes: 6