Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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).

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?

share|improve this question
1  
Why not use the title rather than the question field for the actual question? –  Stephen Harris May 11 '12 at 10:31
    
@StephenHarris because I can't label the title field as a 'Question', it would be unclear to the user what to do. As I mentioned in the question, if anyone can tell me how to relabel that then that's what I would use –  jammypeach May 11 '12 at 10:36

1 Answer 1

up vote 1 down vote accepted

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;
    }
share|improve this answer
    
that's prefect, thanks! one other solution I was playing with was a bit of javascript to hide the title & update the value but this is much more elegant. thanks for sharing :) –  jammypeach May 11 '12 at 12:39

Your Answer

 
discard

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.