Site logo

Archived topic

How to show image caption on all archive pages

1 reply · Started by webcréateur on May 18, 2021

Viewing posts 1–2 of 2

Hi there,

you can use this PHP Snippet:

add_action( 'post_thumbnail_html', 'db_auto_single_featured_caption', 10 );
function db_auto_single_featured_caption( $html ) {
    $caption = get_the_post_thumbnail_caption();
    if ( !is_single() && !empty($caption) ){
      $html .= '<div class="wp-caption">'. $caption . '</div>';
    }
    return $html;
}

Adding PHP: https://docs.generatepress.com/article/adding-php/

This archived topic is closed to new replies.