Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8495767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:39:53+00:00 2026-06-10T23:39:53+00:00

I have a string that contain data formatted through a WYSIWYG editor. But the

  • 0

I have a string that contain data formatted through a WYSIWYG editor. But the generated HTML code is not very well formatted. I would like something as the “the_content()” wordpress function, that delivers a string like this:

Lorem ipsum dolor sit amet, <strong>not properly closed

Another paragraph without p, lorem ipsum dolor m nonummy.

To somethig like this:

<p>Lorem ipsum dolor sit amet, <strong>not properly closed</strong></p>

<p>Another paragraph without p, lorem ipsum dolor m nonummy.</p>

I look up to the wordpress core but without much success (found a force_balance_tags() function, but don’t seems to be what I want).

So… do you guys know some php class/library/code snippet that does that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:39:55+00:00Added an answer on June 10, 2026 at 11:39 pm

    WordPress has a function called wpautop which converts double line-breaks to paragraph elements.

    I would not suggest using a library for correcting the users wrongly formatted HTML though. You would be forced to guess the correct intepretation. (like old browsers did back in the days, and that was not exactly a success).

    As an example, Where should the closing </strong> tag in your code be placed? No one knows!

    I would rather look for (or create) a method to check for unvalid HTML and then notify the user, and let them correct it.

    • PHP function that checks for validity (answer to a SO question)
    • Use the W3C validator API
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have data from a table in a database (string) that contain text and
I have a string that contains HTML image elements that is stored in a
If I have a string that contains the html from a page I just
I have a problem that if I pass a string that contain + in
I have a UTF-8 formatted data file that contains thousands of floating point numbers.
I have a string value that could contain a double, integer, ascii or byte
Say if I have an initial string that could contain either an integer or
I have a string that holds user input. This string can contain various types
I have a String Array which is contain dates that read from a CSV
I have a requirement to sort some strings that contain data like this: var

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.