How can i remove all html tags from get_the_content()?

The WordPress function, at least the one I tend to use, would be wp_filter_nohtml_kses. That should remove all of the HTML, but you need to be careful not to put some HTML back by running the_content filters on your HTML-less string.

I am not sure why strip_tags didn’t work, but I suspect that you doing something else in other code posted or not posted and that that something else is undoing your tag stripping, or putting some tags back. Mainly I think that because you tried …

$content = get_the_content();
$content = apply_filters('the_content', $content);

… and apparently expected tags to be stripped?

Leave a Comment