WordPress.org

Ready to get started?Download WordPress

Forums

Mass remove invalid XHTML tags from posts (7 posts)

  1. DeepBlueTrees
    Member
    Posted 3 years ago #

    Hey all,

    So in an attempt to make my site more XHTML friendly, I would use <p> tags in my posts while using the HTML editor. I thought that since they were inline tags, and they were proper markup, this would work. Turns out that based on the XHTML validation, they are giving me a lot of trouble. I have a few hundred posts now with this problem unfortunately, and I would like to remove these erroneous tags if possible. What's the best way to do this? Thank you

    For reference: The markup validation of my site

    http://validator.w3.org/check?uri=http%3A%2F%2Fdeepbluetrees.com&charset=%28detect+automatically%29&doctype=Inline&group=0

  2. 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.

  3. DeepBlueTrees
    Member
    Posted 3 years ago #

    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 :/

  4. Izvarinskij
    Member
    Posted 3 years ago #

    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
  5. DeepBlueTrees
    Member
    Posted 3 years ago #

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

  6. 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');
    ?>
  7. DeepBlueTrees
    Member
    Posted 3 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic