I’m looking for a WP function that add the Read-only parameter to all Pages’s Titles’s input, that will make the Page’s title unalterable.
Thanks a lot in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This can be accomplished with some simple JavaScript/jQuery. Create a file called admin_title_disable.js, and queue it up within functions.php. For example:
functions.php:
Now, in your js file:
This will set both post and page title input fields with a
disabledattribute. Hope this helps!If you want to restrict this script to a particular admin page, wrap the
add_actionhook in a conditional that compares$_GET['page']. You can also take advantage of the$hookparameter that is available when usingadmin_enqueue_scriptsto check for the page. See here.Update::
WordPress makes it a little tricky to tell between post and page edit screens, but there is a hidden input that you can take advantage of. 🙂 Here’s an updated version of the jQuery that will only run on page edit screens: