WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Post Thumbnails
[resolved] Get the caption of the secondary thumbnail (3 posts)

  1. betadog
    Member
    Posted 2 years ago #

    It's not that easy to display the caption of the regular post thumbnail in WordPress. I finally figured out that this works for me:

    <?php echo get_post(get_post_thumbnail_id())->post_excerpt; ?>

    But how can I display the caption of the secondary thumbnail that I have added using Multiple Post Thumbnails?

    http://wordpress.org/extend/plugins/multiple-post-thumbnails/

    [ Please do not bump, it's not permitted here. ]

  2. zerodegreeburn
    Member
    Posted 1 year ago #

    I'd also like to know how to do this, It's a vital feature for me. I can't find any reference to it in the readme or plugin page.

  3. zerodegreeburn
    Member
    Posted 1 year ago #

    OK I found a way of doing this here:

    <?
    $second_thumbnail_id = get_post_meta(get_the_ID(), "work_second-image_thumbnail_id", false);
    $second_id = $second_thumbnail_id[0];
    
    // The thumbnail caption:
    echo get_post($second_id)->post_excerpt;
    ?>

    I just had to change Change "page_second-image_thumbnail_id" to "work_second-image_thumbnail_id" which is the name of my post_type.

    I hope this helps people out.

    On another note it would be great if there was a way of making WordPress convert line breaks entered into the caption into
    tags, instead of manually adding
    tags at the end of each line in the caption. I guess that's another topic though.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic