Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End [Solved] How can I insert Line breaks in a textarea output?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #32090
    noahgelman
    Participant

    Using Theme Options panel in WP to insert content. Here is the array that builds the option:


    $options[] = array( "name" => "Footer Right Content",
    "desc" => "",
    "id" => $shortname."_footer-right-content",
    "type" => "textarea");

    That gives me a textarea option on the Theme Options panel to insert content, and that’s all fine and dandy, except that the output is in one paragraph so there’s no line breaks. I need to either create the line breaks or split it up into separate paragraphs. How would I do this?

    #54634
    TheLeggett
    Member

    The wpautop() function might be what you’re looking for: http://codex.wordpress.org/Function_Reference/wpautop

    #54620
    noahgelman
    Participant

    That’s exactly what I need. However, I’m having trouble inserting the string. My php isn’t so good so I’m screwing up the syntax

    Here’s the echo that generates the string.

    How can I plug this in to the wpautop()?

    #54613
    TheLeggett
    Member

    I haven’t actually used WordPress Theme options before, so this is just a guess. Hopefully someone corrects me here if I’m wrong.

    I would assume something like this would work:



    Or…


    $foo = get_option('vn_footer-right-content');
    echo wpautop($foo);
    ?>

    #54615
    noahgelman
    Participant

    The second one worked perfectly. I believe the problem with the first one was that the string wasn’t echoed out first and wpautop() must take a string, not a variable. I think so at least, my php isn’t as good as yours clearly. Thank you for your help :)

    #149120
    nizamkazi
    Participant

    I believe that simpler way it to add white-space: pre-wrap; in to css set of element which is displaying the result.

    And it will start reflecting line-break where you had pressed “Enter” while typing into textarea.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Back End’ is closed to new topics and replies.