WordPress.org

Ready to get started?Download WordPress

Forums

How to keep line breaks/paragraphs in image description? (2 posts)

  1. dannyfoo
    Member
    Posted 4 years ago #

    I'm using this code from Dameian to pull the image attachments out.

    However, I've not been able to find a guide on how to keep line breaks in the image description when we upload it.

    Please do share a solution, if you know of one. Thanks.

  2. alchymyth
    The Sweeper & Moderator
    Posted 4 years ago #

    i assume that you simply echo the

    $img_description = $image->post_content; // description.

    try to apply a filter:

    $img_description = $image->post_content; // description.
    echo apply_filters('the_content',$img_description);

    that would wrap the string into paragraph tags and add html line breaks.

Topic Closed

This topic has been closed to new replies.

About this Topic