Simply add the code bellow in your functions.php file inside your theme’s folder. And don’t forget to change the custom field name.

add_action('publish_page', 'add_custom_field_automatically');
add_action('publish_post', 'add_custom_field_automatically');
function add_custom_field_automatically($post_ID) {
	global $wpdb;
	if(!wp_is_post_revision($post_ID)) {
		add_post_meta($post_ID, 'field-name', 'custom value', true);
	}
}

That’s it. Hope this helps.

Get expert 350-030 dumps to keep up with latest tools and techniques in php. Become master of latest technology using 70-642 dumps and N10-004 dumps as well.