Skip to main content
Added jQuery based solution
Source Link
Manny Fleurmond
  • 7.4k
  • 4
  • 41
  • 55

The function that's in charge of saving posts on the database (wp_insert_post) requires at the minimum a title and content:

http://codex.wordpress.org/Function_Reference/wp_insert_post

Edit: I created a quick and dirty jquery solution. Input this in your functions file or in a plugin:

<?php
add_action('admin_head', 'post_title_check');
function post_title_check() {
    ?><script type="text/javascript">
        jQuery(document).ready(function($) {
            $('input[name="save"]').click(function() {
                if($('input[name="post_title"]').val() ==='') {
                    alert("Please input a title");  
                    return false;
                }
            }); 
        });
    </script>'
    <?php   
}
?>

Basically checks to see if the text field is empty. If it is, gives you a message and prevents you from continuing. If it has something in the field, it submits with no issue.

The function that's in charge of saving posts on the database (wp_insert_post) requires at the minimum a title and content:

http://codex.wordpress.org/Function_Reference/wp_insert_post

The function that's in charge of saving posts on the database (wp_insert_post) requires at the minimum a title and content:

http://codex.wordpress.org/Function_Reference/wp_insert_post

Edit: I created a quick and dirty jquery solution. Input this in your functions file or in a plugin:

<?php
add_action('admin_head', 'post_title_check');
function post_title_check() {
    ?><script type="text/javascript">
        jQuery(document).ready(function($) {
            $('input[name="save"]').click(function() {
                if($('input[name="post_title"]').val() ==='') {
                    alert("Please input a title");  
                    return false;
                }
            }); 
        });
    </script>'
    <?php   
}
?>

Basically checks to see if the text field is empty. If it is, gives you a message and prevents you from continuing. If it has something in the field, it submits with no issue.

Source Link
Manny Fleurmond
  • 7.4k
  • 4
  • 41
  • 55

The function that's in charge of saving posts on the database (wp_insert_post) requires at the minimum a title and content:

http://codex.wordpress.org/Function_Reference/wp_insert_post