function create_posttype() {
register_post_type( 'about',
// CPT Options
array(
'labels' => array(
'name' => __( 'About' ),
'singular_name' => __( 'About' )
),
// 'supports' => array('title', 'editor', 'thumbnail'),
'public' => true,
'has_archive' => false,
'rewrite' => array('slug' => 'about'),
)
);
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );
add_theme_support('post-thumbnails');
add_post_type_support( 'about', 'thumbnail' );
function add_description_meta_boxes() {
add_meta_box("about_description_meta", "Description", "add_description_meta_box", "about", "normal", "low");
}
function add_description_meta_box()
{
global $post;
$custom = get_post_custom( $post->ID );
?>
<style>.width99 {width:99%;}</style>
<p>
<label>Description:</label><br />
<textarea rows="5" name="description" class="width99"><?= @$custom["description"][0] ?></textarea>
</p>
<?php
}
function save_description_custom_fields(){
global $post;
if ( $post )
{
update_post_meta($post->ID, "description", @$_POST["description"]);
}
}
add_action( 'admin_init', 'add_description_meta_boxes' );
add_action( 'save_post', 'save_description_custom_fields' );
No comments:
Post a Comment