Return to Snippet

Revision: 36065
at November 17, 2010 14:28 by wpCanyon


Initial Code
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);
	}
}

Initial URL
http://wpcanyon.com/tipsandtricks/adding-a-custom-field-automatically-on-postpage-publish/

Initial Description

                                

Initial Title
Adding A Custom Field Automatically On Post/Page Publish

Initial Tags
wordpress

Initial Language
PHP