• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2754

Original WordPress Tutorials & 6000+ Guaranteed Code

Snippets

  • Premium Access
  • Log in

Remove All HTML Tags From Comment Content Text In WordPress

A premium user asked how to remove links from comments which is the reason for publishing this code.

Add the following PHP code to your child themes functions file.

add_filter( 'comment_text', 'wp_filter_nohtml_kses' );

The code converts this link :

<a href="http://example.com" rel="nofollow">http://example.com</a>

Into this :

<p>http://example.com</p>

So its not clickable and the nofollow attribute has also been removed.

Comments

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting