How to programatically set the post title of a CPT on wp-admin

I’ve been playing with custom post types & custom fields, using a combination of the types plugin and the advanced custom fields plugin, also having done the same manually.

Occasionally I want to create a CPT where a title would be inappropriate – for example, an FAQ where I want two fields labelled Question and Answer. This does work without a title, however they all get saved as (No Title).

Read More

What I’d like to do is either set the title to the value of the Question custom field, or somehow define my own title field that I can label as I like.

Does anyone have any pointers on how to acheive this?

Related posts

Leave a Reply

1 comment

  1. You can use the enter_title_here filter:

        add_filter('enter_title_here','wpse51871_alter_title_label',10,2);
        function wpse51871_alter_title_label($label, $post){
            if( 'question' == get_post_type($post) )
                $label = __('enter question here', 'my-plugin-text-domain');
    
            return $label;
        }