如何在Wordpress中为损坏的远程服务器URL设置默认缩略图?

We have 4000 remote server thumbnail urls as dp_video_poster meta key in wp_postmeta in our wordpress database.

Those 4000 urls are all broken (404 not found) on remote server. We want to set default thumbnail for those broken ones on our own server. How can we do it by adding php code into one of our wordpress files?

You can replace all of the broken images with the path to your thumbnail, there shouldn't be the need to implement PHP code. First, get your broken urls:

SELECT id FROM imageTable WHERE ... #For the broken URLs

Then you can run an UPDATE statement to replace the invalid URLs with your placeholder-URL:

UPDATE imageTable SET url = :placeholderUrl
  WHERE id IN (
    SELECT id FROM imageTable WHERE ... #Conditions for broken URLs
  )

Using this query, all of your broken URLs are now replaced with the value of :placeholderUrl. I suggest to create a backup beforehand, you never know what a little mistake might cause.