Title: Need to replace some html code
Last modified: August 19, 2016

---

# Need to replace some html code

 *  [Morten Dalgaard Johansen](https://wordpress.org/support/users/iosoftgame/)
 * (@iosoftgame)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/need-to-replace-some-html-code/)
 * Hello everyone.
 * I need some help with a problem because I have tried all the solutions I could
   think of and nothing seems to work.
 * What I need is a plugin/filter which replaces lines like these:
    `<td width="
   1" height="24" valign="top"> </td>` with: `<td width="1" height="24" valign="
   top"></td>` removing the space between the tags.
 * I have coded the following PHP code, but it simply doesn’t work.
 *     ```
       <?php
       /*
       Plugin Name: MyFilter
       */
   
       function my_filter($text)
       {
       $text = str_replace('> </td>', '></td>', $text);
       return $text;
       }
   
       add_filter('the_content', 'my_filter');
       ?>
       ```
   
 * I have tried with a simpel “substr_count” call, but that can neather find any
   linies in the content provided by WordPress – and I know it’s there, because 
   I can see it in the source in my browser.
 * I have tried to copy the HTML code from the WordPress page created with the visuel
   editor into a stand-a-lone PHP file and used the above function, which works 
   as it should.
 * I hope that somebody can see the error and help me with a solution.
 * In advance, thanks
 * Best regards
    Morten Johansen

The topic ‘Need to replace some html code’ is closed to new replies.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [filter](https://wordpress.org/support/topic-tag/filter/)

 * 0 replies
 * 1 participant
 * Last reply from: [Morten Dalgaard Johansen](https://wordpress.org/support/users/iosoftgame/)
 * Last activity: [15 years, 10 months ago](https://wordpress.org/support/topic/need-to-replace-some-html-code/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
