Draw Service type for particular post

Here is the idea. Posts can be type of Fire, Snow, Thunder, Cold, Wind, or Water. Just imagine.

WordPress Dashboard can hold post types in some $meta_box_value:

function _draw_services(){

global $post;

$meta_box_value = get_post_meta($post->ID, 'service', true);



if(1 == $meta_box_value)

	echo '<input type="radio" checked="checked" name="service" value="1" /> Fire';

else

	echo '<input type="radio" name="service" value="1" /> Fire';



if(2 == $meta_box_value)

	echo '<input type="radio" checked="checked" name="service" value="2" /> Snow';

else

	echo '<input type="radio" name="service" value="2" /> Snow';



if(3 == $meta_box_value)

	echo '<input type="radio" checked="checked" name="service" value="3" /> Thunder';

else

	echo '<input type="radio" name="service" value="3" /> Thunder';



if(4 == $meta_box_value)

	echo '<input type="radio" checked="checked" name="service" value="4" /> Cold';

else

	echo '<input type="radio" name="service" value="4" /> Cold';



if(5 == $meta_box_value)

	echo '<input type="radio" checked="checked" name="service" value="5" /> Wind';

else

	echo '<input type="radio" name="service" value="5" /> Wind';



if(6 == $meta_box_value)

	echo '<input type="radio" checked="checked" name="service" value="6" /> Water';

else

	echo '<input type="radio" name="service" value="6" /> Water';

}</code>

Action add_meta_boxes can take our function _services metabox to a post.

add_action( 'add_meta_boxes', 'add_custom_metaboxes');

/add custom meta boxes function/

function add_custom_metaboxes() {

// the next line is for playlists only for adding custom metabox for playlists!

$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;



/*post*/

add_meta_box(

		'_services',

		'Select the service type',

		'_draw_services',

		'post'

);

}</code>

on post update we need to manage

$service = $_POST['service'];

update_post_meta($post_id, ‘service’, $service);

</code>

services


Thanks

tags: & category: -