WordPress: Advanced Custom Fields, Custom Post Types And The Dreaded Auto-Draft Title

This post today is not an in-depth look into using Advanced Custom Fields, or Custom Post Types, or CPT-UI. I just wanted to briefly explain the problem and then show the solution that has worked for me.

The problem

After setting up a new Custom Post Type (CPT) in WordPress using CPT-UI you will see the new type displayed at left in the admin menu. You click on the item and with no posts created yet you’ll see “No Projects Found” (in my example). All behaving as expected for now.

You then set-up Advanced Custom Fields (ACF) to override the default Title and WYSIWYG editor presented by WordPress when adding a new entry for your CPT—because ACF is awesome.

Well if you’ve told CPT-UI when creating your CPT to not display the title (image below), because you wanted ACF to take over that job, WordPress will essentially not save a title value for your new CPT posts.

cpt-ui

 

Now when creating new entries for your CPT without a title value the main admin page for your custom post type looks like this:

cpt-ui-autodraft

 

The Solution

While you might immediately think, “I’ll just leave the Title showing in CPT-UI” what happens is that whether your new CPT is Projects, Books, Movies, whatever… the first field will read “Enter title here” which might not always be the best for your custom post type.

To change that text easily to read whatever you wish, add this code to your functions.php file:

The only values above you need to change to make this your own: the word “projects” (use your own custom post type name), and the value for ‘Enter new project name here’;

Hope this helps you out!

I know there are other ways of doing things. If you have a better way or want to share how you do it—leave a comment below.

Tags: , , , ,

Leave a Reply

Other tags used in my blog:

 (1)  (6)  (1)  (16)  (1)  (1)  (17)  (1)  (17)  (1)  (1)  (7)  (1)  (4)  (15)  (5)  (2)  (28)  (9)  (1)  (12)  (4)  (1)  (4)  (5)  (9)  (1)  (6)  (1)  (4)  (1)  (1)  (1)  (3)  (1)  (3)  (4)  (7)  (3)  (3)  (4)  (1)  (1)  (2)  (1)  (7)  (11)  (12)  (2)  (6)  (1)  (3)  (16)  (2)  (3)  (1)  (5)  (1)  (28)  (4)  (4)  (9)