开发者

PHP code to show featured image caption if it exists

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\them开发者_JAVA百科es\BuilderChild-Default\extensions\magazine-enhanced2\functions.php:88:syntax error, unexpected T_ECHO

Please help.


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>'; 
  }
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜