Support

Account

Home Forums Front-end Issues Auto Draft as title

Solved

Auto Draft as title

  • Heya everyone!

    I’m trying to get my WordPress skills up lately, after doing some research I found multiple tools to work with, including things as ACF and Timber. I’m currently trying to develop a website using WordPress and am having a problem.

    I made a custom post type by adding a function in functions.php, this post type does not have a title nor content. I did add the following fields to this post type it: a brand, a name, a postal code, an address and an image field. Adding a post of this type works completely fine, though, it’s title is ‘Auto Draft’.

    I would like the title to be a concatenation of the brand and the name field, instead of ‘Auto Draft’. Is there a way to accomplish this and if there is: is this considered good practise? For example: would simply keeping the standard title field be a better option?

    Thanks,

    jdreg95

  • I’ve used this in several cases and wouldn’t consider it a bad practice. The WP title field has no way to insure that something like a unique product must be added. this can be done with ACF.

    You can use the validate value hook to make sure a value is unique like outlined here https://support.advancedcustomfields.com/forums/topic/accept-only-unique-values/

    and you can use acf save post hook to convert the fields into the post title, I posted an example of this here https://support.advancedcustomfields.com/forums/topic/delete-wp-title-and-use-acf-title/

  • Hi John,

    The save post hook worked! Though, why would I have to use the validate value hook? Do post titles have to be unique?

    jdreg95

  • I was thinking if you wanted to have a unique titles for each post, I’ve done this when creating something similar to make sure the client can’t add two posts with the same brand + name. If you don’t need that you can just ignore that part of my comment.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Auto Draft as title’ is closed to new replies.