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); ?> |
That’s it. Place above code into your theme's function.php file and run the code into browser :).
Read:
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)