$template_file) { if ($template_file == get_post_meta($post->ID, '_wp_post_template', true)) { $selected = 'selected'; } else { $selected = ''; } $opt = ''; echo $opt; } } function krakatau_get_post_template($template) { global $post; $custom_field = get_post_meta($post->ID, '_wp_post_template', true); if(!empty($custom_field) && file_exists(get_template_directory() . "/{$custom_field}")) { $template = get_template_directory() . "/{$custom_field}"; } return $template; } function krakatau_pt_add_custom_box() { if(krakatau_templates() ) { add_meta_box( 'krakatau_pt_post_templates', __( 'blogazine style', 'krakatau' ), 'krakatau_pt_inner_custom_box', 'post', 'normal', 'high' ); } } function krakatau_pt_inner_custom_box() { global $post; echo ''; echo '
'; echo ''; echo '

' . __('Please select the style you want by clicking the dropdown menu above. There are two styles to blogazine if you do not select it, then it will be the default single post, still confused? Just visit my blog http://amdhas.tk', 'krakatau' ) . '

'; } function krakatau_pt_save_postdata($post_id, $post) { if ( !wp_verify_nonce( $_POST['krakatau_pt_noncename'], basename(__FILE__) )) { return $post->ID; } if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can( 'edit_page', $post->ID )) return $post->ID; } else { if ( !current_user_can( 'edit_post', $post->ID )) return $post->ID; } $mydata['_wp_post_template'] = $_POST['_wp_post_template']; foreach ($mydata as $key => $value) { if( $post->post_type == 'revision' ) return; $value = implode(',', (array)$value); if(get_post_meta($post->ID, $key, FALSE)) { update_post_meta($post->ID, $key, $value); } else { add_post_meta($post->ID, $key, $value); } if(!$value) delete_post_meta($post->ID, $key); } } ?>