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?

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" />';
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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