Search code examples
wordpresspluginsrichtextbox

Add a rich text field in a wordpress plugin settings


I'm working on a simple wordpress plugin that adds a functionality to some of the pages. I need a titel (which I've made with a simple input field) and then a body text(custom message), where I want to use rich text. Is it possible to add a Rich Text Field to my settings page for my plugin?

Thanks, Kasper

Screen shot of the settings page


Solution

  • You have to use wp_editor() function. Simple example is:

    wp_editor( array(), 'custom_message', array(
        'textarea_rows' => 9
    ) );
    

    Here you create rich text field with empty content ( array() ), id=custom_message, and set property to make it 9 rows high.

    Add this in your code where you create simple input "Custom title".