Title: Removing  tags in Functions.php?
Last modified: August 21, 2016

---

# Removing tags in Functions.php?

 *  [Patagia](https://wordpress.org/support/users/patagia/)
 * (@patagia)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/removing-tags-in-functionsphp/)
 * I’ve been trying to remove the <p> tags from an image from this website I’m working
   on. The white space between the menu and the content is where the image should
   be. If I view the source and remove the <p> tags myself, the image displays normally.
 * [http://hoffmastergroupinc.tushausweb.com/](http://hoffmastergroupinc.tushausweb.com/)
 * I’m using a function (in functions.php) to remove <p> tags surrounding an image,
   but it doesn’t appear to be working.
 *     ```
       function filter_ptags_on_images($content){
           return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
       }
       add_filter('the_content', 'filter_ptags_on_images');
       ```
   
 * Am I doing it wrong? Help on this would be much appreciated.

The topic ‘Removing tags in Functions.php?’ is closed to new replies.

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [tags](https://wordpress.org/support/topic-tag/tags/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Patagia](https://wordpress.org/support/users/patagia/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/removing-tags-in-functionsphp/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
