More than 800+ satisfied clients and counting, since 2010

Blog

How to disable HTML tags from WordPress?

WordPress has always been, since it’s inception in 2003, an open source software and online platform that has been providing free of cost domain space to users all over the internet to create and publish their ideas, opinions, experience and suggestion regarding anything in form of  blogs that have readership of over ten million and is constantly on the rise which is a result of it’s enhanced and premier features which are under constant construction and upgradation of a core team that retrieves ideas and suggestions from the users and coders around the globe who contribute to WordPress through their intellect. The WordPress core community, through a stream of comments received in WordPress open forums regarding the annoying presence of HTML tags in the post body and the increased usage of these tags by spammers to promote their links, has worked upon certain changes and amendments in already existing content so as to remove this drawback of WordPress. Not just this, many programmers, who also have been WordPress users, have in fact turned in many solutions ranging over script changes to short alterations in functions.php, that may actually solve this problem. Similar corrective measures, which can be performed by non programmers, have been mentioned in this article. This article shall cover both, the body HTML tag removal as well as the comment HTML tags removal procedures. So, read through to know how to disable HTML tags from WordPress.

Primarily, addressing the tag removal in comments section we have many tags such as <strong>, <font> etc that are used in spam comments by bots and many scripts, which in a way can be prevented by disabling HTML tags in WordPress.  To go ahead on this, you will have to open your functions.php file and add the code mentioned below :

add_filter(‘comment_text’, ‘wp_filter_nohtml_kses’);

add_filter(‘comment_text_rss’, ‘wp_filter_nohtml_kses’);

add_filter(‘comment_excerpt’, ‘wp_filter_nohtml_kses’);

This method does not require a core file alteration which could be risky but in case anyone wants to try it, you will have to open wp-includes/kses.php and edit your codes there.

If you are one of those who although are in love with WordPress for various reasons but still cannot reconcile with the <p> tags that just keep cropping up into your posts, many a times ruining the content display, we have a solution here.  ‘wpautop’ in WordPress carries out the job of putting <p> tags around every paragraph or element in post editor window which is great, but sometimes, like when using an image in your post, it puts script tags around the picture that has not so good effects on the display of the blog. To overcome this particular issue we have a very basic solution of using a raw HTML plugin although it can also be done by editing the functions.php file by adding the following code :

remove_filter(‘the_content’, ‘wpautop’);

But the users should use the much recommended raw HTML plugin that not only turns off wpautop from adding <p> tags but also cuts short all other filters  according each post and page i.e. user can allow tags in particular posts or pages.

Written by

The author didnt add any Information to his profile yet