Back to Top

How to add TinyMCE editor to Category Description?

html editor

Today I am going to explain how to add WYSIWYG editor to category description. Sometimes you want detailed HTML text as a description in category page so you can mostly prefer to use the plugin but which is not good to use the plugin because we can do it with small piece of code.

In this article, I will explain function which enables the WordPress TinyMCE editor on the Edit Category page of the admin panel and you can add/edit the descriptions the same way you add/edit posts content.

Let’s understand by code:

First of all, we use filter hook which edit category form and replace text area with an editor.Then after I have used action hook which is used to set style sheet of an editor.

add_filter('edit_category_form_fields', 'edit_cat_description');
function edit_cat_description($category) { 
    $tag_extra_fields = get_option(description1);?>
true, 'media_buttons' => true, 'quicktags' => true, 'textarea_rows' => '15', 'textarea_name' => 'description' ); wp_editor(html_entity_decode($category->description , ENT_QUOTES, 'UTF-8'), 'description1', $settings); ?>
true, 'media_buttons' => true, 'quicktags' => true, 'textarea_rows' => '15', 'textarea_name' => 'description' ); wp_editor(html_entity_decode($tag->description , ENT_QUOTES, 'UTF-8'), 'description1', $settings); ?>
php endif; }

That’s it. Place above code into your theme's function.php file and run the code into browser :).


Convert RGB to Hex HTML code in PHP
The DocType In HTML
Clean HTML content in PHP

Hope this helps someone else out.As always, thanks for reading. Don't Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Comments (6)

  1. I have use this code, it is running fine,
    Thanks for this nice code

  2. This work with woocommerce category description?
    It did not work for me

    1. This code is not for woocommerce category description. For woocommerce category description, you need to use woocommence action hooks.

  3. it did add wysiwyg but when I save it every thing is lost

  4. Amazing, thank you! But i think, for save description in html format need add:

    // allow html in category and taxonomy descriptions
    remove_filter( 'pre_term_description', 'wp_filter_kses' );
    remove_filter( 'pre_link_description', 'wp_filter_kses' );
    remove_filter( 'pre_link_notes', 'wp_filter_kses' );
    remove_filter( 'term_description', 'wp_kses_data' );

  5. Hi,

    How about on taxonomy? I think it works only on the category but not on the taxonomies

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

An Introduction To NoSQL and MongoDB

Posted on 7 years ago


How to use JavaScript Promise API?

Posted on 2 years ago


How to get started with AngularJS

Posted on 4 years ago


Hello world

Updated 1 week ago

Nick Carter

In depth Understanding of Laravel Core

Updated 2 months ago


ECMAScript 6 New Features – 2

Updated 1 year ago


The Reader’s Poll – June 2015

Posted on 4 years ago


The Reader’s Poll – August 2014

Posted on 4 years ago


The Reader’s Poll – June 2014

Posted on 5 years ago


The Readers’ Poll – May 2014

Posted on 5 years ago


The Readers’ Poll – August 2013

Posted on 5 years ago