hide a featured image caption
-
The following is what I use to check for a featured image with caption:
<?php // Checking for a post thumbnail if ( has_post_thumbnail() ) { ?> <div style="float:left; width:auto; padding-right:5px;"> <div style="float:left; position:relative;"> <?php the_post_thumbnail("news-large", array('class' => 'enewspost')); echo '<div style="width:auto;"><p class="wp-caption-thumbnail">'.get_post(get_post_thumbnail_id())->post_excerpt. '</p></div>'; ?> </div> </div> <div> <?php the_content();?> </div> <?php } else { ?>
the <p class wp-caption> has styling elements like grey background, my question is:
If the caption is empty, how can I get the <p class> to hide?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘hide a featured image caption’ is closed to new replies.