07967 325669 info@mootpoint.org

Sometimes when you’re updating a WordPress site by replacing the theme, you may need to remove shortcodes which were added by the old theme, perhaps by a page builder module. It can be very tedious to strip the shortcodes manually, so the simplest way is to perform a search and replace on the wp_posts table in the database.

  1. First, back up your database!
  2. It’s always advisable to use a serialised data-safe search method in WordPress databases, so download theĀ Database Search and Replace Script from interconnect/it.
  3. Once you’ve placed the script on your web server, fire it up and select the “use regex” checkbox, and the multiline (“m”) and “s” parameters.
  4. Select the “select tables” radio, and highlight the wp_posts table (you may have a different table prefix).
  5. Enter the following pattern in the search field (which is labeled “replace”):
    \[\/?shortcode_name(.+?)?\]

    replacing shortcode_name with the name of the shortcode you wish to remove.

    This pattern will find both opening and closing shortcodes, but leave any text between them, which is probably what you want.

  6. Click Dry Run, and carefully check the sample results to make sure it’s doing what you expected.
  7. Finally, when you’re ready to actually make the changes to the database, and are sure you have backed up your database, click Live Run.