How to add WYSIWYG Editor to TextArea Custom Meta Box in WordPress?

Custom Meta Boxes are super fun. They are very essential when building Plugins or Themes which contain much more advanced functionalities.

So let’s see how to create a Custom Meta Box with Textarea input?

Part 1. Create the Meta Box

2. Add your Textarea input field

3. Function to fetch the Value of Meta Box

4. Function to Save the Values of Meta on Admin Screen

Now, these 4 Things will Ensure that we get a Textarea Metabox and its values are being properly saved and being output wherever we want.

Now the Problem with a textarea is that a regular user doesn’t know a lot of HTML code. So he cannot create stuff like unordered lists, or format the text easily. So we need to replace the textarea created in part 2 with a WYSIWYG Editor. Everything else remains the same.

Creating a WYSIWYG Editor

Delete the Code you added in STEP 2 and replace it with the following:

That’s it and the code is complete. Enjoy your WYSIWYG Custom Meta box, if you are facing any difficulty comment below and I will try to help you out.

Leave a Reply

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