0

I'd like to create a simple action hook that fires whenever I open a post for editing in the WordPress back-end. What hook(s) can/should I use for this? The action would just be a simple echo command that prints text to the screen (as this is only for testing purposes).

Thanks.

  • Depends on what you want to do. Do you want to echo html code or run a procedure? – Laxmana Apr 27 '17 at 11:43
  • @Laxmana OK that's interesting to know. I was hoping to just echo text right now, as a proof-of-concept test. But indeed my ultimate goal in this experiment is to print to the screen the 'name' attribute of a particular field on the page ('price'), per these instructions: reigelgallarde.me/programming/…. So I guess my ultimate goal is to also echo HTML code. – cag8f Apr 27 '17 at 12:21
  • I see. I think you are asking the wrong question. You should search how to add a custom field to a post type or find a plugin that does that. There is a lot of tutorials over the Internet. – Laxmana Apr 27 '17 at 12:30
  • @Laxmana Yep. Your question made me realize that I actually need to get back to the drawing board on this question. I still learned a little from Rishabh's answer though. – cag8f Apr 27 '17 at 12:36
2

Don't what you want to do but here is something that I did earlier on editor page of post type.

function wpb_change_title_text( $title ){
    $screen = get_current_screen();

    if  ( 'post' == $screen->post_type ) {                //Specify post type
        $title = 'New Placeholder text will come here ';  //Enter new placeholder text
    }

    return $title;
}

add_filter( 'enter_title_here', 'wpb_change_title_text' );

This function will change placeholder text of title textbox of any post type, here I am changing text of post (dashboard -> add post).

  • OK great, that worked as expected. I will use this to continue my testing. We can consider this question answered.start – cag8f Apr 27 '17 at 12:28
  • Here is an another example in which you can add content by default in text area of post type wpbeginner.com/wp-tutorials/… – Rishabh Apr 27 '17 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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