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

To build upon @s_ha_dum's answer I think you want.

$content = get_the_content(); 
echo wp_filter_nohtml_kses( $content ); //or strip_tags

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?


This removes both <htmltags> and <!-- comments -->:

echo wp_strip_all_tags( get_the_content() );

wp_filter_nohtml_kses() didn't get me rid of the comments.

seen here