WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to force user to set featured image on some types of posts. For example I've got custom post type mm_photo and I want to show some error message or somehow block user from publishing or updating post when there is no featured image set.

share|improve this question
Have you also considered using fall-back images in your template if none is supplied? There was a similar question/answer posted here – Zach Nov 30 '12 at 14:23
Try to adapt this and update your Question. And this will help you write a better Q. – brasofilo Nov 30 '12 at 14:32

Fairly simple using jQuery and global $typenow ex:

add_action('admin_print_scripts-post.php', 'my_publish_admin_hook');
add_action('admin_print_scripts-post-new.php', 'my_publish_admin_hook');
function my_publish_admin_hook(){
    global $typenow;
    if (in_array($typenow, array('post','page','mm_photo '))){
        <script language="javascript" type="text/javascript">
            jQuery(document).ready(function() {
                jQuery('#post').submit(function() {
                    if (jQuery("#set-post-thumbnail").find('img').size() > 0) {
                        return true;
                        alert("please set a featured image!!!");
                        return false;
                    return false;

share|improve this answer

Try the answer here: http://stackoverflow.com/a/13575967

To repeat the code from that answer:

function featured_image_requirement() {

     if(!has_post_thumbnail()) {

          wp_die( 'You forgot to set the featured image. Click the back button on your browser and set it.' ); 



add_action( 'pre_post_update', 'featured_image_requirement' );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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