I have a custom meta "code" in my CPT. How can I make it so that it has a number that will auto increment every time the admin publishes a post?

My solution is to add a table in the database that is "code". Every time the user publishes a post, it will add 1 to the code table. Then I will use a script to append the code from the db to the meta. But it does not seem to add in the db.

Please present alternative/better solutions.

  • Please update the question with the relevant codes you have been working with? – Maruti Mohanty Dec 12 '13 at 6:51
  • 1
    Meta fields are associated to posts in WordPress, which the 'code' meta the 'code' field is associated to? – gmazzap Dec 12 '13 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.