WordPress / PHP / Magic Fields Strip unnecessary HTML Tags while leaving the ones you want


HI Its really annoying when WordPress sometimes adds tags in multiline text inputs when you really dont need them. So to get rid of those tags you can use the following php function,

strip_tags(string,allow)

Here the string part refers to the string that your getting through WordPress or maybe as a Magic fields input field. and you can use the allow part to allow any tags that you might actually want to leave in the out put.

Ex:

strip_tags($postextract, '<a><ul>');

This will actually strip all HTML tags leaving anchor tags and UL tags in the output. Pretty useful hack. 🙂

Reference :

Advertisements

Let me know what you think .. :)

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s