wp_kses_post() WordPress Function

The wp_kses_post() function in WordPress is used to filter content in a post or page. The function strips out all invalid or dangerous HTML code from the content, making it safe to post on a WordPress site. This function is important to use because it helps to protect your site from malicious code that could potentially harm your site or its visitors.

wp_kses_post( string $data ) #

Sanitizes content for allowed HTML tags for post content.


Description

Post content refers to the page contents of the ‘post’ type and not $_POST data from forms.

This function expects unslashed data.


Top ↑

Parameters

$data

(string)(Required)Post content to filter.


Top ↑

Return

(string) Filtered post content with allowed HTML tags and attributes intact.


Top ↑

Source

File: wp-includes/kses.php

function wp_kses_post( $data ) {
	return wp_kses( $data, 'post' );
}


Top ↑

Changelog

Changelog
VersionDescription
2.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.