skip to Main Content

I imported hundreds of posts from Drupal to WordPress, and they all came in nicely. I did not create the content on Drupal, and I’m discovering that all of the posts have multiple

enter image description here

statements at the top, which is driving down the top of the content with blank lines. These are appearing in the inspector as

enter image description here

I can’t edit each of these hundreds of posts, so I’m hoping there’s a way with code (CSS (unlikely), JavaScript?) to hide any p with that character/code as its only content.

Tried CSS, but can’t hide things like this with it.

2

Answers


  1. Chosen as BEST ANSWER

    Thanks all. I used Dai's suggestion and did a search/replace to remove all the statements from the DB.


  2. You can u the code below to remove all tags with only contain space inside:

    const isNotMarked = el => {
            while (el && el.parentNode && !el.parentNode.marked) {
               el = el.parentNode;
               if (el.marked) { return false }
            }
            return true;
        }
        [...document.querySelectorAll("span, p, strong")]
            .filter(el => el.textContent.trim() === "" && isNotMarked(el) ? el.marked = true : false)
            .forEach(el => el.parentNode.removeChild(el));
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search