-
inoruhana
I would like to remove the following code in all my posts:
<!– wp:latest-posts {“categories”:[{“id”:…,”value”:”….”}],”postsToShow”:100,”postLayout”:”grid”,”columns”:6,”order”:”asc”} /–>
What should I do without editing every single post? -
George
Hello,
Since the code you want to remove is identical across all posts, the cleanest way to do this without editing each one is a bulk find-and-replace directly on your database. I’d recommend the Better Search Replace plugin (free on WordPress.org):
- Install and activate Better Search Replace.
- Go to Tools → Better Search Replace.
- In the “Search for” field, paste the exact block string you want to remove:
<!-- wp:latest-posts {"categories":[...],"postsToShow":100,"postLayout":"grid","columns":6,"order":"asc"} /--> - Leave “Replace with” empty.
- Select the
wp_poststable. - Run a dry run first (check “Run as dry run?”) to confirm how many matches it finds, then run it for real once you’re happy.
A couple of things worth flagging:
- The block code stored in your database uses straight quotes (
") and standard dashes, not the curly quotes/dashes shown in your message — so make sure you copy the exact string from the post editor’s Code view, or the replace won’t match. - If the block parameters (category IDs, etc.) differ from post to post, a single search string won’t catch them all. In that case you may need a few passes or a more flexible approach.
- Back up your database first. Search-and-replace on
wp_postsis irreversible.
This sits a little outside GeneratePress support since it’s a core WordPress block, but the method above should sort it out.
This sits a little outside GeneratePress support since it’s a core WordPress block, but the method above should sort it out.
-
inoruhana
Thank you for your kind response.
I was using SSH with some commands and all the same codes in thousands of posts were removed immediately.
So grateful. -
George
Glad to know you are sorted!
- You must be logged in to reply to this topic.