I'm trying to setup a fallback image for featured image.

The main problem I have is miss of filter for get_the_post_thumbnail_url(). I'm using this function to echo thumb url in many-many templates, because it is easy customizable. So, this is not a solution to make an if-condition for each usage. And even to set default image for blank featured image, because it may be changed.

I see that I might apply filter to get_post_thumbnail_id(), but most likely I need an external URL to this fallback image, hardcoded in this theme. But, even if I can't apply external image, how can I make default image for get_the_post_thumbnail_url() function?

  • what is the code that you've tried?
    – rudtek
    Commented Oct 5, 2017 at 22:43

2 Answers 2


I would say you can't, not possible. There is no filter for get_the_post_thumbnail_url() or get_post_thumbnail_id().

However you could apply a filter to get_metadata() which get_post_thumbnail_id() uses, and return the id of another attachment that you want to use as the default thumbnail. But I don't recommend this it's a bit hacky.

I think you should refactor your code and just make a function to check if get_post_thumbnail_id returns anything.


Perhaps hook into save_post?

  1. check that featured image is NOT set during save
  2. then set default featured image post_meta _thumbnail_id


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.