Viewing 4 replies - 1 through 4 (of 4 total)
  • there is no div in the pastebin code – you might need to post/paste more code such as the full code of the template you are working with.

    to be able to check conditionally if there is caption text, you might need to re-write the functions to return the text instead of echoing it.

    Thread Starter pixelrow

    (@pixelrow)

    Apologies this is correct code that I have modified to use:

    https://pastebin.com/9zA1psg5

    This is how I display it:

    <div class="f_image">
     <?php if ( has_post_thumbnail()) : ?>
       <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" > <?php the_post_thumbnail(); ?>
    <?php the_post_thumbnail_caption(); ?></a>
     <?php endif; ?>
    
    </div>

    and the CSS:

    https://pastebin.com/0aZSTEWP

    —-

    All help is appreciated.

    try and change this line:

    echo '<div class="f_caption"><h3>'.$thumbnail_image[0]->post_excerpt.'</h3></div>';

    to:

    if( $thumbnail_image[0]->post_excerpt ) echo '<div class="f_caption"><h3>'.$thumbnail_image[0]->post_excerpt.'</h3></div>';

    Thread Starter pixelrow

    (@pixelrow)

    alchymyth

    Thank you so much – you are genius and a star. I offer you a virtual handshake.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Displaying Featured Image Caption’ is closed to new replies.