Support » Fixing WordPress » Mass remove invalid XHTML tags from posts

Viewing 6 replies - 1 through 6 (of 6 total)
  • Chris Olbekson

    (@c3mdigital)

    Level 12 Bug Squasher & Forum Moderator

    Were you using the visual or html editor when you entered all your posts?

    Also do you have the option correct invalidly nested XHTML automatically checked in writing settings? If this is checked WP will fix errors like forgetting to close tags.

    If your using the visual editor you should never put html tags in your posts. If your using the html editor if leave out the tags word press will add them for you and if you add them it will leave them without adding them again.

    Thanks for the reply! I was adding them using the HTML editor. Adding them using the visual editor would have been a disaster.

    I do have the option set to properly nest tags.

    I use an FTP client to upload my files which copies the full URL of the file, so it’s easier to just type out the full link anchor tag for media linking. I’ll stop using the paragraph tags but I guess I’m just looking for a way to fix the markup errors :/

    You don’t need to add <p> tags, they are added automatically by WordPress.

    Instead of

    <p>Paragraph 1</p>
    <p>Paragraph 2</p>

    use

    Paragraph 1
    
    Paragraph 2

    Yep. Any way to remove the ones that are already there without editing each one individually?

    Chris Olbekson

    (@c3mdigital)

    Level 12 Bug Squasher & Forum Moderator

    You could right a function to remove them such as this:

    <?php
    // functions
    function clear_br($content){
    	return str_replace("<br />","</p><p>", $content);
    }
    add_filter('the_content', 'clear_br');
    ?>

    Looks like exactly what I’m looking for. Would it just replace the extra tag with a line break tag?

    How would I go about executing this function?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Mass remove invalid XHTML tags from posts’ is closed to new replies.