I was trying to replace my video link in my wordpress site to another subdomain, I have got a small issue with attached video files.
Under meta_value:
old link: https://example.com/wp-content/uplaods/2022/09/file.mp4
new link: https://newlink.com/my_files/myvids/2022/09/file.mp4
When I run this code:
UPDATE wp_postmeta SET meta_value = replace(meta_value,'old_url.com','new_url.com');
But the problem is that meta_key is same for images and videos: meta_key is: _wp_attached_file
So when I change the link it affects image link as well, however I just want to change the links that contain only mp4 files in meta_value and meta_key with _wp_attached_file . so is there any way to just change the link that contain video files such as .mp4 for example?
Appreciate that.
Regards,
2
Answers
If I understand your question correctly, you should be able to solve it by adding
where meta_value like '%mp4'
.You have t6o add a WHERE clause to your Update so that only the values for example with ening mp4 will be updated
db<>fiddle here