In this post, I’ll outline how to make the post title field required for a custom post type in WordPress. By default, if a user leaves the title field blank, WordPress will still allow the post to be published or updated. What we want to do is prevent the custom post type from being published/updated until it has a valid title, and let the user know they need to enter one.
Next, create a new file named km_dashboard_admin.js in a text editor and paste in this code:
That’s it! If you want to require post titles for multiple post types, you can change the km_load_admin_scripts() function to contain the snippet below, with your post types in the list: