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'm using the enter_title_here filter to modify the 'Enter title here' text in a custom post type, question is what hook should I use to trigger this function?

I have used admin_enqueue_script as a test and it worked, but I think there is a better hook since this is not really a script.

    function print_scripts() { 
    $screen = get_current_screen();
    if ( 'post' === $screen->base && 'myposttype' === $screen->post_type ) {
        wp_enqueue_style( 'styles', WP_CSS . 'styles.css' );
        // filter used here
        add_filter( 'enter_title_here', function() { _e("Enter name here"); } );
    }  
    }

    add_action( 'admin_enqueue_scripts', 'print_scripts' );
share|improve this question
    
You just need to call the filter enter_title_here. No action hook is required for that. Yes, for enqueuing the script, admin_enqueue_scripts will do. –  Rutwick Gangurde Aug 22 '12 at 10:26
    
ok so it's all good like that. –  drtanz Aug 23 '12 at 9:17
add comment

2 Answers

I believe it's a simple difference, here; you are echoing with e() - try returning with _() instead:

function custom_title_text( $title ){ return __( 'Enter Name here' ); } add_filter( 'enter_title_here', 'custom_title_text' );

share|improve this answer
    
I think I didn't explain myself very clearly the first time round, see edited question now please. I would like to know if I'm using the correct action hook or not. –  drtanz Aug 22 '12 at 8:14
    
I can use the function you suggested, and then I would have to include those if statements (is there a better way to make that conditional?), and then fire that function on a hook, but which hook? admin_enqueue_scripts works, but is there a more appropriate hook for this? –  drtanz Aug 22 '12 at 8:33
add comment
up vote 0 down vote accepted

Answer was the one by @RutwickGangurde: You just need to call the filter enter_title_here. No action hook is required for that. Yes, for enqueuing the script, admin_enqueue_scripts will do.

share|improve this answer
add comment

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.