I created a new wordpress page and added this into the Text tab (NOT the visual tab. The visual tab is disabled):


When I click Publish, the code turns into this:


How do I stop it from doing that?? The website displays the code like text and not HTML, so you literally see "&lt;div&gt;&lt;/div&gt;" on the page. I even tried adding a replace script into the functions.php file and it didn't work:

function my_content_filter( $content ) {
    $new_content = str_replace('&gt;','>',$content);
    return $new_content;
add_filter( 'the_content', 'my_content_filter', 1 );

I should also note that I have tried to use a shortcode/snippet plugin to add HTML to the page and it still comes out with entity code.

  • 1
    Are you editing on the Text or Visual tab? Mar 1, 2018 at 4:19
  • I'm editing in the Text tab
    – Dawn
    Mar 1, 2018 at 16:20
  • I removed my answer as if you are using the text editor it is mostly irrelevant, but still, you should avoid using it as a way to craft HTML in wordpress. Wordpress is a CMS and any specific raw HTML should to happen in a shortcode or page/theme template. No matter how good you structure you HTML in the editor it will always be a bummer for anyone else to edit it. Mar 1, 2018 at 17:34
  • Does the user have the unfiltered_html capability? Mar 1, 2018 at 17:41
  • I'm the Super Admin on the site so I should have all capabilities.
    – Dawn
    Mar 1, 2018 at 18:47

1 Answer 1


I'm 99% certain you're editing in the Visual tab and need to be adding HTML in the Text tab. Change to the Text tab in the upper right and paste the HTML code in there.

If for some insane reason this is happening from the Text tab, disable all plugins and themes and make sure it's not one of them causing it.

If it's still happening, peace be with you, and add this to your functions:

function dawn_content_filter( $content ) {
    return html_entity_decode( $content );
add_filter( 'the_content', 'dawn_content_filter', 1 );

For the editor, you can use this function to convert the content that's displayed in the editor. Keep in mind this will prevent you from being able to display code samples on your site because it will convert html entities into parseable html code. I'd still recommend checking for plugin/theme issues to make sure the issue doesn't reside there.

function dawn_editor_filter( $content ) {
    return html_entity_decode( $content );
add_filter( 'the_editor_content', 'dawn_editor_filter', 1 );
  • I am 100% certain I am NOT editing in the visual tab. I actually have the visual tab disabled. I wish I could post a video here of what happens. I am editing in the text tab and when I hit "publish" the content changes to entity code. But your function code seems to work. Thank you!
    – Dawn
    Mar 1, 2018 at 16:05
  • It's interesting because the website is rendering HTML fine now, but the text editor is still showing code like this: &lt;div class="mainContentWrapper mainContent mainContent-contactUs"&gt;&lt;div class="contactFormWrapper"&gt;&lt;h1&gt;Contact Us Today To Get Started&lt;/h1&gt;
    – Dawn
    Mar 1, 2018 at 16:11
  • I'm sad I got downvoted on an answer that worked. I'd still recommend checking for plugin/theme conflicts, or making sure the current user has proper permissions (including unfiltered_html) - I have however update the answer to include a function that will "fix" the content in the editor as well. note: that this won't all you to "display" code samples by using HTML entities since they'll be converted to actual HTML code as well.
    – Xhynk
    Mar 1, 2018 at 18:13
  • I'm sorry, I wasn't the one that down voted you. I upvoted you but I don't think that will change the publicly displayed score. When I changed your fix, it fixed the content in the editor, but it renders HTML entities. When I use your previous version, the editor shows entities, but the website renders HTML just fine. UGH. I'm going to check for plugin/theme conflicts.
    – Dawn
    Mar 1, 2018 at 18:23
  • Your functions code both work!!! I disabled all the plugins and there were no conflicts which makes me think it is in the theme or the wordpress update. Your code works and for now I'll figure out what's causing this issue. Thank you so much!!!
    – Dawn
    Mar 1, 2018 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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