stirling web design and development

Strip images and other HTML from a WordPress post

Wordpress code snippet when you want to retrieve a certain piece of info from a post.

Here’s a really quick snippet for when you’re building a custom post loop in WordPress. It’s really easy to remove the images or any other nasty html that could mess up the theme that you’ve spent hours designing, just put the tags in the functions that you’d like to keep and hey presto you’ve got the post content clean and only showing the tags you want……useful.

1
<?php echo nl2br(strip_tags(get_the_content(''),"<strong><em><em><a>")); ?>