Created
April 11, 2023 10:19
-
-
Save JoryHogeveen/c8fea62f39c6d73c357d42a3dc4b400f to your computer and use it in GitHub Desktop.
WP Metadata: Convert image URL to image ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Below SQL will convert an attachment URL to the attachment ID | |
# Useful when switching from Toolset to Pods or ACF. | |
UPDATE wp_postmeta m | |
LEFT JOIN wp_postmeta s | |
ON INSTR( m.meta_value, s.meta_value ) > 0 | |
SET m.meta_value = s.post_id | |
WHERE | |
s.meta_key = '_wp_attached_file' | |
AND m.meta_key = 'YOUR_META_KEY' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment