Skip to content
Advertisement

Auto fill a Custom Post Type title from ACF field

I’d like to auto fill the title of three Custom Post Types (CPTs) based on an ACF field. I found the code below, but don’t know how to write it for three CPTs instead of just one. I would appreciate the help!

JavaScript

Advertisement

Answer

Try this code. It should work for you.

JavaScript

Update

Replace the previous code with the following. It will resolve the double title issue as noted by Andrew in below comment.

JavaScript

Tested and working on:

  1. WordPress 5.0.3
  2. Twentyninteen 1.2
  3. Advanced Custom Fields PRO 5.7.10
  4. Localhost (XAMPP for Windows 5.6.15)
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement