0

I am looking for a way to disable the editing of a post's title when on post.php.

I want the title of a post to remain "fixed", but editing of the content to be possible.

 function my_remove_meta_boxes() {
     if( !current_user_can('delete_published_posts') ) {  
         remove_meta_box('titlediv', 'post', 'normal');
     }  
 }  
 add_action( 'admin_menu', 'my_remove_meta_boxes' );`

This will completely remove the title box, which somewhat achieves the goal, but I would ideally like to still be able to actually display the Title - just that it can't be edited

  • You have posted multiple questions, all of which have received upvoted answers, you should consider marking them as correct if they solved your question. – Christine Cooper Nov 19 '13 at 20:42
1

You can use a simple jQuery code to disable the title field.

jQuery(document).ready(function() {
poststatus = /* get this from your php code */
if( poststatus != "auto-draft" ) {
jQuery( "#title" ).attr( 'disabled', true );
});

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.