I've removed "Title" from a custom post type that I created. Which makes it that all new posts gets the name "Auto Draft".

To get around this I want to be able to fetch a value/post name from a meta box and save that as the new title. Is this possible?

Now i need to when i save new post i need to set post title like this

matches_first x matches_second

where matches_first is meta box 1 and matches_second is meta box 2

1 Answer 1


Why do you need to remove the title? Generally it's a bad idea, as the title generates the permalink, can't think of any scenario where it would be necessary.

Anyways, here is some code that looks like it does what you need:

function add_custom_title( $data, $postarr ) {
    if($data['post_type'] == 'myposttype') {
        if(empty($data['post_title']) {
            // here would go the code to construct your custom title
            $data['post_title'] = 'my post title';
    return $data;

add_filters('wp_insert_post_data', 'add_custom_title', 10, 2 );

src: http://premium.wpmudev.org/forums/topic/assign-default-title-to-custom-post-types

  • no no i need the title, but i need the titel = matches_first x matches_second Jun 28, 2014 at 11:36
  • What do "matches_first x matches_second" represent? Do you refer to a regular expression that is part of a custom rewrite rule when the user is looking at page? Jun 30, 2014 at 16:03
  • Oh, sorry, read again, you refer to a custom field value... Then, you would use the get_post_meta() to retrieve the values and then construct your title... You could use a print_r($data) to see how to access the id of the current post... Jun 30, 2014 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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