How to add html in category description in WordPress
As per the default functionality, we are not able to use any html tags in category description textbox in wordpress admin. WordPress prepared this section for normal content. So, to make it possible, wordpress prepared a filter and put it with all default filters. WordPress placed this filter here :
wp-includes/default-filters.php
Sometimes we need html content in the category description section to fulfill our requirement. So, we need to get rid of this default functionality.
Solutions :
There are few plugins available for it, but as per me using a plugin for such small tasks is not a good choice, we can do this by adding a line of code easily. To make this possible we have two approaches :
1. Wrong Approach :
1. Just open the file “default-filters.php” which exists here : “wp-includes/default-filters.php”.
2. Search for this code :
add_filter($filter, 'wp_filter_kses');
3. Comment out or remove this code, you are done.
But as the name indicates, it is a wrong approach because we do not recommend any modifications in core files of wordpress. This is a bad practice.
2. Correct Approach :
As the name indicates, it is a correct approach because here we are not modifying any core file. We just need to put a line of code in our current theme’s functions.php file. This will remove that filter which is responsible to removing these html tags. Put the below mentioned code at the end of your functions.php file :
remove_filter('pre_term_description', 'wp_filter_kses');
So, use the correct approach and add above line to your code. Now check, you are able to insert any html tags in your category description section.
Enjoy Quick website development with wordpress 🙂
Leave a Reply