Skip to content

Instantly share code, notes, and snippets.

@MogulChris
Created January 24, 2022 00:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MogulChris/e1682cc47b3dd408678310d5b317072c to your computer and use it in GitHub Desktop.
Save MogulChris/e1682cc47b3dd408678310d5b317072c to your computer and use it in GitHub Desktop.
MySQL / PHPMyAdmin find and replace of Elementor data
# Points to note:
# 1. Elementor data is saved as JSON in wp_postmeta with meta_key _elementor_data
# 2. The LIKE operator needs four backslashes for every one in the JSON data you are looking for.
# 3. The REPLACE function needs two backslashes for every one in the find / replace strings.
# 4. Eg: Searching for buttons with a particular label and linking to "/" - I want to change their links to /case-studies
update `wp_3_postmeta` set meta_value = REPLACE(meta_value, '"button_label":"View All","button_link":"\\/','"button_label":"View All","button_link":"\\/case-studies') WHERE meta_key = '_elementor_data' AND meta_value LIKE '%"button_label":"View All","button_link":"\\\\/"%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment