Support » Fixing WordPress » Fix Auto Draft Title, use custom field instead

  • I created a post type, and then allowed only the editor, page-attributes, revisions, and comments for the page. I intentionally left out title. I then have a metabox with some fields. After entering in the metabox fields and publishing, I notice the title is actually “auto draft” when I look at the single page or the post listings for it.

    I don’t want to use the standard title box to enter the title either, I actually want to use one of the custom fields to replace it. But I don’t just want to mask it. I actually want to have the custom field saved as the actual title for the post also. This way when I look at the single page as well as the list of posts, it appears correctly there. I just can’t seem to find a solution.

Viewing 4 replies - 1 through 4 (of 4 total)
  • This stuff was originally posted here.

    But I just tweaked it to work for 1 custom field to replace the title. It works perfect (thus far)!!!

    add_filter('title_save_pre', 'save_title');
    function save_title($my_post_title) {
            if ($_POST['post_type'] == 'post_type_name') :
              $new_title = $_POST['custom_field_name'];
              $my_post_title = $new_title;
            return $my_post_title;
    add_filter('name_save_pre', 'save_name');
    function save_name($my_post_name) {
            if ($_POST['post_type'] == 'post_type_name') :
              $new_name = $_POST['custom_field_name'];
              $my_post_name = $new_name;
            return $my_post_name;

    this doesn’t work for me but I can’t figure out why. it seems like the right way to do it. but when I hit save it doesn’t save the post. it also screws up my permalinks.

    try this

    the code below sets the value of the hidden field, to the value of a custom field of your choice.
    this tricks wordpress into saving the hidden field as the title 🙂

    <div id=”titlewrap”>
    <input type=”hidden” name=”post_title” size=”30″ tabindex=”1″ value=”” id=”title” autocomplete=”off” />

    <script type=”text/javascript”>
    $( ‘#customfieldofchoice’ ).blur( function () {
    $( ‘#title’ ).val($( ‘#customfieldofchoice’ ).val());

    @jonnyplow: Thank you. This works great for me when I’m updating a custom post.

    However, when I save a post for the first time the title doesn’t get saved. Is there another hook I need to use for triggering the function on a first save?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Fix Auto Draft Title, use custom field instead’ is closed to new replies.