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

I searched around and the URL below is all I could find on this problem. If I publish a custom post type's post without entering in a post title, it wipes the whole post's info and says "published". However, the post is nowhere to be seen. Looking into the database, I can see the post is created, but it's set to auto draft. The post_name value is empty

Found this. Sounds like exactly what I'm experiencing http://www.wptavern.com/forum/plugins-hacks/1851-custom-post-type-posts-published-without-title-lost.html

Any ideas on how to fix this? Or maybe someone can suggest a way of checking to see if a post title exists when the post it published, and display a error message to the user?

Update Thanks to Manny's solution below, I managed to make a few modifications from WordPress prompt checklist before publish? and fix the publish button so it doesn't keep spinning when you close the alert box.

add_action('admin_head', 'post_title_check');
function post_title_check() { ?>

<script type="text/javascript">
    jQuery(document).ready(function() {
        jQuery('#post').submit(function() {

            if(jQuery('input[name="post_title"]').val() == '') {
                alert("Please input a title");  

               return false;  


share|improve this question
Is the title field active on your custom post type? – Manny Fleurmond Aug 24 '11 at 10:31
@manny Yes it is – Andrew Aug 25 '11 at 0:45
up vote 2 down vote accepted

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


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

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;

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.

share|improve this answer
Do you know of a way to somehow stop the post from publishing if there is no title present? I don't think it's very user-friendly if someone fills in the whole post (I have quite a few custom fields etc) clicks publish without entering a title and has everything disappear. My custom post type only supports title. editor has been removed. – Andrew Aug 24 '11 at 10:32
@Andrew added a solution that should work, though it could use some work to be more transparent. Someone with more knowlede could probably give a better solution – Manny Fleurmond Aug 25 '11 at 3:21
hey thanks for that, took yours, changed it a little bit to fix the publish button based on another post I found on here. – Andrew Sep 2 '11 at 7:23
@andrew can you post the updated code? I'd love to see what change you made. – Manny Fleurmond Sep 2 '11 at 13:40
Hey Manny, I put it in my original question unless it's not showing up for some reason :) – Andrew Sep 2 '11 at 14:06

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.