Among all of the features that wordpress has, taxonomy is an important one. Cause all the posts of different post types are categoried here with different taxonomies. ‘Category’ is a such one that comes in wordpress by default for the posts. You may find already that , as an admin you have the ability to create category providing its name, slug, description. But, ever you looked at the field for description ! Boring, isn’t it? How would it be , if it could be a tinmyce editor like the one that a post editor panel has. Let’s try something to do that
Get started !
You might have seen that , in category panel there list page where in the left one can create a new category using the form, here there is a description field. Another one is in the edit page of already created category. Both these two are plaing textarea. We are gonna change these two now.
Firstly a point that i wanna mention is that, there are two filters that trigger in two different pages. One in the list page of category which is called “category_add_form_fields” and another in the edit panel of category page which is called “edit_category_form_fields” . We are going to hook a function with these two filters that is going to add the wordpress tinymce editor. Thus we will get our desired editor in both pages.
add_filter('category_add_form_fields', 'cat_description'); add_filter('edit_category_form_fields', 'cat_description'); function cat_description($tag) { ?> <div> <table class="form-table"> <tr class="form-field"> <td> <div><label for="description"><?php _ex('Description', 'Taxonomy Description'); ?></label></div> <?php $settings = array('quicktags' => true, 'textarea_name' => 'description' ); wp_editor(wp_kses_post($tag->description , ENT_QUOTES, 'UTF-8'), 'cat_description', $settings); ?> <br /> <span class="description"><?php _e('You can write something here as description !'); ?></span> </td> </tr> </table> </div> <?php }
We have done it but we also need to remove category’s default textarea , caue we don’t need that anymore. So, let’s add a function to run when admin_head action triggers.
add_action('admin_head', 'remove_default_category_description'); function remove_default_category_description() { global $current_screen; if ( $current_screen->id == 'edit-category' ) { ?> <script type="text/javascript"> jQuery(function($) { $('textarea#description').closest('tr.form-field').remove(); $('#tag-description').remove(); }); </script> <?php } }
‘wp_kses_post’ and ‘wp_kses_data’ are wordpress function that strip html when displaying the content , so we need to remove those. Cause, some we may want to add description as html. Add this code for that.
remove_filter( 'pre_term_description', 'wp_filter_kses' ); remove_filter( 'term_description', 'wp_kses_data' );
That’s it ! Pretty cool, right ? Hope, you will be able to add description how you want now . 🙂
Hope you will feel free to share and let others know what knew. Thank you 🙂
Is this possible for the tag section aswell??
#done
nvm the question is just as stupid as i am 🙁 sorry
Yes, it’s possible as it is in case of category. 🙂
Wow, this article is pleasant, my younger sister is analyzing these things, therefore I am going to convey her.
Thanks, glad to know it helpful
I really like what you guys are up too. This kind of clever work and reporting!
Keep up the very good works guys I’ve added you guys to our
blogroll.
Thanks a lot 🙂
I visited many blogs however the audio feature
for audio songs existing at this web page is in fact fabulous.
Sweet blog! I found it while browsing on Yahoo News.
Do you have any tips on how to get listed in Yahoo News?
I’ve been trying for a while but I never seem to get there!
Cheers
Hello, I think your blog might be having browser compatibility issues.
When I look at your blog in Ie, it looks fine but when opening in Internet
Explorer, it has some overlapping. I just wanted to give you a
quick heads up! Other then that, wonderful blog!
Hello my loved one! I wish to say that this article is
awesome, great written and include approximately all important infos.
I’d like to peer extra posts like this .
Hiya! I know this is kinda off topic nevertheless I’d figured I’d ask.
Would you be interested in trading links or maybe guest authoring a blog post or vice-versa?
My blog addresses a lot of the same subjects as yours and I believe we could greatly benefit from each
other. If you might be interested feel free to send me an email.
I look forward to hearing from you! Superb blog by the way!
I blog often and I genuinely appreciate your content.
This great article has really peaked my interest. I’m
going to book mark your site and keep checking for new details about once per week.
I subscribed to your RSS feed as well.
My brother suggested I might like this blog. He was totally right.
This post actually made my day. You can not imagine simply how much time I had spent for this info!
Thanks!
Welcome, Glad to know this post helpful 🙂
You should be a part of a contest for one of the most useful blogs on the net. I’m going to recommend this web site!
Very good information. Lucky me I found your blog by accident (stumbleupon). I have book marked it for later!
Hi! Would you mind if I share your blog with my twitter group?
There’s a lot of people that I think would really appreciate your content.
Please let me know. Cheers
Fantastic post but I was wondering if you could write a litte more on this subject?
I’d be very thankful if you could elaborate a little bit
more. Bless you!