5

Is there a way to add a TinyMCE editor to the taxonomy description field on the term editing pages? The solution here (Can you add the visual editor to the description field for custom taxonomies?) no longer works, I think because the wp_tiny_mce function has been deprecated.

2 Answers 2

19
+50

You can use a {$taxonomy}_edit_form_fields action hook to add html to the term edit table. In that HTML you can remove description textarea and add tinymce editor

add_action("{$taxonomy}_edit_form_fields", 'add_form_fields_example', 10, 2);

function add_form_fields_example($term, $taxonomy){
    ?>
    <tr valign="top">
        <th scope="row">Description</th>
        <td>
            <?php wp_editor(html_entity_decode($term->description), 'description', array('media_buttons' => false)); ?>
            <script>
                jQuery(window).ready(function(){
                    jQuery('label[for=description]').parent().parent().remove();
                });
            </script>
        </td>
    </tr>
    <?php
} 
6
  • Oleg, I'll try this first thing in the morning.
    – Josh M
    Jun 8, 2015 at 18:57
  • About to test. By the way, you have a typo on line 3, "function." :)
    – Josh M
    Jun 8, 2015 at 20:03
  • I am really sorry about that. Thanks userabuser for fixing my typo. (I was about to go home yesterday due a terrible headache when I deside to post response on 'one more' question here.) Jun 9, 2015 at 7:17
  • I get "Undefined variable: taxonomy". How does this work? I put it in functions.php Aug 14, 2017 at 18:32
  • I've tried the code and it's working, but the thing is I don't know to apply it to my issue: wordpress.stackexchange.com/questions/318814/… Nov 10, 2018 at 5:20
4

For those still looking for a solution to this problem, it's worth mentioning that the Yoast SEO plugin adds a WYSIWYG editor for descriptions automatically on the taxonomy term edit screen.

If you're not planning to use that plugin for SEO please don't add it only for this functionality. Given the plugin's popularity, I figured it was worth noting it here since it could save time for someone who already plans to install the plugin.

4
  • Where is this setting if you don't mind me asking? Is this a premium feature or apart of the free plugin? I don't see this working with free...
    – lcm
    Feb 10, 2021 at 9:35
  • @lcm, it was part of the free plugin and I'm pretty sure it activated automatically. Try it on a fresh WordPress install and if it works, then there's likely something breaking the functionality. It might also be worth checking the console to see if you're getting any JavaScript errors.
    – jg314
    Feb 10, 2021 at 13:04
  • Looks like this is only on the Edit Screen, but not on the Add screen. So first you will need to add it then edit it to see the full editor.
    – ggedde
    May 26, 2021 at 21:48
  • It's also worth noting that you have to enable Show SEO Settings for the Taxonomy within Yoast settings for that taxonomy in order for the wysiwyg to kick in. There are some Taxonomies I'm using for organization purposes but don't want the actual archive page indexed but I still have that setting turned on just to enable the wysiwyg on the description box. yesterday

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.