Is there a simple (and without plugin) way to clean up the WordPress output of HTML? With a beautiful indentation of the code? I don't understand why, but my HTML output isn't perfect and it makes me uncomfortable.

  • You might be able to use ob_start() and ob_get_clean() to capture all the output before it's written. Next, you would just need a mechanism to indent nested tags. – jgraup Feb 11 '17 at 19:18
  • See: stackoverflow.com/a/12243304 – jgraup Feb 11 '17 at 19:28
  • downvoted, as by itself adding "in wordpress" to basic PHP questions to not make them on topic. Your main issue is how to use php to format HTML to match some specific style. As for "my style is not perfect", if the W#C checker do not report errors on your pages, than it is perfect – Mark Kaplun Jun 25 at 13:34

If I'm correct, you want to display HTML in your post output with indentation. There is no inbuilt way of doing it. You have to do some manual work, here's a link to a tutorial. This will help you understand how to write code in WordPress blog posts without using any plugins.

Check out the WordPress Codex too.

  • No, no, I mean the source code of the page (alt+cmd+U) – William Ode Feb 11 '17 at 13:50
  • So the actual HTML output of the pages? – devkabiir Feb 11 '17 at 13:51
  • To my knowledge, this isn't possible because a lot of plugins hook their functions to final output and to do what you want, it will require you to edit all the plugins you use and some of the WordPress core files too, along with the theme files. My advice is to copy the source code and use an IDE or a text editor like Atom to correct the indentation in your code and then utilize it how you please. – devkabiir Feb 11 '17 at 13:55

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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