0

I'm currently using the_post_thumbnail(); to display featured images in my pages.

Is it possible to set a fallback placeholder image in the event a featured image hasn't been set?

1 Answer 1

3

You can use has_post_thumbnail() as condition and change output accordingly.

Example from Codex:

if(has_post_thumbnail()) {
    the_post_thumbnail();
} else {
    echo '<img src="'.get_bloginfo("template_url").'/images/img-default.png" />';
}
3

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.