I’ve created an ACF field on a Custom Post Type, can that field be auto populated with the Custom Post Type ID?
You use an acf/prepare_field filter.
I have net tested how to get the post ID in a while. You might get it from global $post;
or by using get_queryied_object()
or you might need to use $_GET['post']
.
I am a novice at ACF, and am not sure where to place the snippets of code you have suggested.
Actions and filters are generally placed into your theme’s functions.php file.
Like I said Im a novice. I placed this code in the functions file and dont see any change to the field when I go to the custom post type in wordpress custom_post_type_id = global $post;
I was able to piece together some code to get this to work. Thank you for leading me in the right direction. Here is the full code if anyone else is interested.
add_filter('acf/load_field/name=custom_post_type_id', function($field) {
$id = get_the_ID();
$field['default_value'] = __($id, 'txtdomain');
return $field;
});