Return to Snippet

Revision: 37801
at December 17, 2010 09:11 by Yahosh


Initial Code
<?php

// Add Custom Inputs
add_action("admin_init", "admin_init");
add_action("save_post", "save_post");

function admin_init() {
	add_meta_box( "sectionID", "Section Name", "add_fields", "post-type", "side", "low" );
}

function add_fields() {
	global $post;
	$custom = get_post_custom( $post->ID );
	$fieldName = $custom["fieldName"][0];
	wp_nonce_field("metaNonce", 'metaNonce'); ?>
	
	<label>Field Name:</label>
	<input type="text" size="31" name="fieldName" value="<?php echo $fieldName; ?>" /> <?php
}

function save_post() {
	global $post;
	if ( wp_verify_nonce( $_POST['metaNonce'], 'metaNonce' ) ) {
		update_post_meta( $post->ID, "fieldName", $_POST["fieldName"] );
	}
}

?>

Initial URL


Initial Description
Enables you to add a custom panel in the admin post section for a custom field input

Initial Title
WP - Custom Admin Inputs

Initial Tags
wordpress

Initial Language
PHP