WordPress.org

Ready to get started?Download WordPress

Forums

Caption on Featured image (13 posts)

  1. GlobalChange
    Member
    Posted 2 years ago #

    Hi,
    I would like to add a caption on the featured image. The caption only appears if the image is inputted manually into the post. There have been other requests for this in the past (see link http://wordpress.org/support/topic/display-caption-with-the_post_thumbnail?replies=10). However, since I am not a programmer and know little about code I need some help to find out where this code would even go. I think this is an important feature becuase it has to do with copy right law. I do not want to post images that I cannot cite the source. So far I have not been able to publicize my cite becuase of this concern. Can anyone help with some information on what the code is and where I can input it into my template?
    Thank You
    http://www.globalregimechange.com

  2. Jonas Grumby
    Member
    Posted 2 years ago #

    Lots of posts on this:

    http://wordpress.org/search/featured+image+caption

    Unfortunately none of them are marked Resolved, which means you'll have to sift through them to see if any of them contain an answer.

  3. GlobalChange
    Member
    Posted 2 years ago #

    Thanks Jonas,
    Yeah these are great. I tried looking through all these before. Not even sure which one makes sense. Or where to look in my own template editor. Is it under Feature.php? I now these are basic questions but that's why I am here.

  4. Jonas Grumby
    Member
    Posted 2 years ago #

    It seems like nobody has found a way so far. I also checked the Codex and didn't find anything.

  5. GlobalChange
    Member
    Posted 2 years ago #

    Ug Ok thanks. Maybe they will update it in a future release! Do you know How I can reach out to the developers?

  6. GlobalChange
    Member
    Posted 2 years ago #

    Submitted at ticket for this. maybe they can add to next version.

  7. Jonas Grumby
    Member
    Posted 2 years ago #

    There is an area in these forums for Feature Requests and Feedback.

    http://wordpress.org/support/forum/requests-and-feedback

  8. esmi
    Forum Moderator
    Posted 2 years ago #

    It should be possible to do this by using get_post_thumbnail_id and get_posts.

  9. GlobalChange
    Member
    Posted 2 years ago #

    function get_post_thumbnail_caption() {
    	if ( $thumb = get_post_thumbnail_id() )
    		return get_post( $thumb )->post_excerpt;

    Then you can just do something along the lines of:

    if ( has_post_thumbnail() ) {
    	the_post_thumbnail( 'medium' );
    	echo wpautop( get_post_thumbnail_caption() );
    }

    This is what support has provided. Now where do I put this? Below is what I have in my feature.php
    ------------------------------------------------------------------------------------------------

    [excessive code moderated - please use the pastebin for any code longer than 10 lines]

  10. Jeremy Herve
    Member
    Posted 2 years ago #

    Add the following to your functions.php file:

    function get_post_thumbnail_caption() {
    	if ( $thumb = get_post_thumbnail_id() )
    		return get_post( $thumb )->post_excerpt;
    }

    And then in your feature.php file, find <?php echo $slide_image_thumbnail; ?>, and add the following below:

    <?php echo wpautop( get_post_thumbnail_caption() ); ?>

    That should do the trick.

  11. GlobalChange
    Member
    Posted 2 years ago #

    Yep I did it an nothing happened. Strange. At least it did not change anything :)

  12. GlobalChange
    Member
    Posted 2 years ago #

    Here is the original Featured.php code on pastebin

    http://pastebin.com/FkBFpTeA

    And here is the original function.php code on pastebin

    http://pastebin.com/5KhYRDzQ

    can someone tell me whats wrong? or input the code where its supposed to go?
    Thank you and much gratitude!!

  13. GlobalChange
    Member
    Posted 2 years ago #

    So I am still trying to figure this out. It's really important to give people credit for their art even if it's under CC domain. I would like to ensure that I sight sources on the pics on my site. I tried the above suggestions but to no avail. I posted the code that I have above in a paste bin. Can someone drop the code in. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic