WordPress.org

Ready to get started?Download WordPress

Forums

String Replace. (2 posts)

  1. frankfolk
    Member
    Posted 2 years ago #

    Hello.

    I am creating a wordpress site for a client and i am experiencing a problem.

    When creating a post from the dashboard pressing enter only creates a line break rather than a paragraph. So it moves it to a new line instead of having a space between the paragraphs.

    So i figure what i have to do is a string replace that finds
    tags and replaces them with <p> tags. The only thing is i actually have no idea how to it haha. So my div i am calling in the content using the <?php the_content(); ?>

    Where do i go from here? I apologize because i don't like creating such an open question but i really don't know where to start with it...

  2. frankfolk
    Member
    Posted 2 years ago #

    Right, i have amended someone else's code and i believe this should work.

    function replace_content($content)
    {
    	$content = str_replace('/n', '<p></p>',$content);
    	return $content;
    }
    add_filter('the_content','replace_content');

Topic Closed

This topic has been closed to new replies.

About this Topic