Still trying to get the answer, i don't really know wordpress core (but i'm actually pretty good in PHP), I can't find how to add caption to my images in posts.

I know we can use get_posts to any thumbnail outside it, but inside i need to custom "the_content()" display.

Does anyone have an idea to help me ?

Thanks ! Matthieu

  • It is not very clear what are you asking. Thumbnails are not used in content, so what is exactly the question? Commented Apr 11, 2016 at 5:30
  • You don't need any special coding for image caption, if you add caption/desc in while uploading or by editing image, that will automatically adds caption to the image
    – bravokeyl
    Commented Apr 11, 2016 at 5:53
  • Are you asking about thumbnail caption ?
    – bravokeyl
    Commented Apr 11, 2016 at 5:54
  • Are you trying to output the caption in the loop or programatically from a custom made function? Are you referring to the featured image or to all the images attached to a post? If it's the last case for both answers, I have just answered the question here: wordpress.stackexchange.com/questions/221533/…
    – Luis Sanz
    Commented Apr 11, 2016 at 7:09
  • I want images (thumbnail of not) in my content (when you call the_content() or get_the_content()) to be rendered like this : <figure> <img src="image.jpg" alt="" /> <figcaption>Caption / Description</figcaption> </figure> My question is also about practices on Wordpress, how should we process/modify the content ? With a filter ? If yes how ? Thanks :)
    – Matt Loye
    Commented Apr 11, 2016 at 23:50

1 Answer 1

  <?php echo get_the_post_thumbnail( null, $size, $attr ); ?>
  <figcaption>here goes your caption</figcaption>

for the_post_thumbnail check : https://developer.wordpress.org/reference/functions/the_post_thumbnail/

  • I'm sorry but my question seems not to be clear, i will manage to be more accurate in previous post.
    – Matt Loye
    Commented Apr 11, 2016 at 23:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.