Site logo

[Resolved] Featured Image doesn’t show description

Home Forums Support [Resolved] Featured Image doesn’t show description

Home Forums Support Featured Image doesn’t show description

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1689327
    Kathrin

    Hi, I have written a description that is linked to the featured image but it isn’t shown? What could be the problem?

    Greetings Kathrin

    #1689541
    David
    Staff
    Customer Support

    Hi there,

    Featured images don’t display Captions or Descriptions by default.
    If you want to add the Description below the single post featured image then add this PHP Snippet to your site:

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

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

    Then a little CSS:

    .featured-image .wp-caption {
      line-height: 2em;
      font-size: 0.8em;
      text-align: left;
    }
    #1689882
    Kathrin

    Oh 🙂 Thank you very much! I will try it!

    Works great!

    Greetings Kathrin

    #1689909
    David
    Staff
    Customer Support

    Glad to hear that!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.