wp_filter_nohtml_kses()WP 2.1.0

Strips all of the HTML tags in the given content. Receives a slashed string (content). Returns the cleared content.

$data parameter expects a slashed string (content). If you pass a non-slashed string, the function slash special characters and return back the slashed string! See. example.

This function expects slashed data.

Uses: wp_kses()

No Hooks.


String. Filtered content without any HTML.


wp_filter_nohtml_kses( $data );
$data(string) (required)
Content to strip all HTML from.



#1 Remove HTML from text

This example shows how to clear text and remove all HTML tags from it. Pay attention to the character slashing:

$data = '
	<h2> Текст с кавычками "</h2>
	<span>Еще текст</span>

echo wp_filter_nohtml_kses( $data );

// Выведет (переносы строк и табы сохранены): 

	 Текст с кавычками \"
	Еще текст


$data = wp_slash( $data );
echo wp_filter_nohtml_kses( $data );


	 Текст с кавычками \"
	Еще текст



Since 2.1.0 Introduced.

wp_filter_nohtml_kses() code WP 6.5.2

function wp_filter_nohtml_kses( $data ) {
	return addslashes( wp_kses( stripslashes( $data ), 'strip' ) );