How to Add HTML Scripts in WordPress Category Descriptions

Submitted on July 23, 2011 by

WordPress has many great functions that can enhance the appearance, search engine page ranks, functionality, usability and many more things. One of these things is HTML codes and scripts in category descriptions. First thing, let us understand what a category description box is. Category description can be used to describe the type of posts you have in that page. This will let a visitor know about the subject of your site.

These descriptions are also very important to use as a SEO technique. The problem with WordPress is that it has some strong filters and they automatically block and code or script in the description box. Sometimes, adding a HTML script in the category box can really make the site more useful. All you have to do is to disable those filters from theme editor before using the script. That way you can easily use a code for image or a site enhancing JaveScript in the WordPress description box. Now let us look at the process of disabling WordPress filters.

WordPress Filter Disabling

The WordPress category description box is for describing the category of that page; at least that is what WordPress has to say in the help menu. You can do magic with codes and scripts if you know what to do and how to do it. The best part of the WordPress category description is that you can use any HTML scripts for enhancing your WordPress site by first disabling the filters and then writing your scripts. To do so, first open your WordPress theme editor. There you will find the functions.php file of your theme. Open the file and find PHP closing tag ?> and add the bellow code just before it.

$filters = array(‘term_description’,'category_description’,'pre_term_description’);
foreach ( $filters as $filter ) {
remove_filter($filter, ‘wptexturize’);
remove_filter($filter, ‘convert_chars’);
remove_filter($filter, ‘wpautop’);
remove_filter($filter, ‘wp_filter_kses’);
remove_filter($filter, ‘strip_tags’);
}

This will disable the filters and make the WordPress category description box HTML script friendly. You can use it for scripting purpose now.

Before you add this code to the functions.php file, there are things that you must know. Editing these files require total confidence and some experience. If you write the above code wrong then your WordPress site will be blocked and you will not be able to access it. Go for it only when you know what you are doing and if you absolutely need it. However, if something goes wrong you can always recover the site. Open that functions.php file using FTP and delete your added code. When the file returns to the default form, your WordPress site becomes active again.

Category description in theme

The category description option is not included in the themes. You have to enable the function in your theme. Only by doing that, you can have the category description box in your site and then write HTML scripts in it. Go to your theme editor and open archive.php file. In that file, locate the category headline and add the below code after that.

Now the category description box is ready for your HTML scripts. Use them according to your liking and make your WordPress site more advanced.

Tags:
  Add HTML Scripts in WordPress, How to Add HTML Scripts, HTML scripts in wordpress,

POST YOUR COMMENTS