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.