Home › Forums › General Issues › Create a number field with Auto increment Value › Reply To: Create a number field with Auto increment Value
Thank you for your response.
This method worked to me:
add_filter( 'wp_insert_post_data' , 'odin_prj_title' , 10, 2 );
function odin_prj_title( $data , $postarr )
{
if( $data['post_type'] == 'prj' && $data['post_status'] != 'publish' ) {
$count_posts = wp_count_posts('prj');
$published_posts = $count_posts->publish;
$data['post_title'] = 'P0' . ($published_posts + 1);
}
return $data;
}
https://wordpress.stackexchange.com/posts/296509/revisions
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.