Skip to content

Trouble with textarea in TinyMCE Editor

Came across an issue where the TinyMCE editor inside WordPress was stripping out <textarea> tags as I switched between the HTML and Visual editors, and the page I was working on needed a textarea.

After digging through Google I came across a pretty good reason. A textarea inside another textarea can cause problems so they’re not allowed. Makes sense, but not really a solution.

What I did was add a bit of code to my theme functions.php file to create a pseudo shortcode.

function allow_textareas($content) {
	return preg_replace(

It’s not really a true short code, but it does work. And I didn’t want to do an actual short code because I would have to worry about the different possible attributes. Regex allowed me to just replace what I needed to and leave the rest.

Now all I have to do is [textarea][/textarea] and the function takes care of replacing it with the right HTML tags.

Published inWordPress


  1. This worked beautifully for me. I had searched everywhere online to get the textarea to work. Thanks so much for this!

    • Glad I could help.

  2. Shirish Shirish

    I am facing same issue, but I didn’t found functions.php file in tinymce folder .

    • Functions.php is in your theme folder, not the TinyMCE folder.

Leave a Reply

Your email address will not be published. Required fields are marked *