Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action( 'init', 'shawnrisk_create_homeslider' );
- add_action( 'add_meta_boxes', 'shawnrisk_add_meta_boxes' );
- add_action('save_post', 'shawnrisk_save_homeslider_details');
- add_action('manage_posts_custom_columns', 'shawnrisk_homeslider_custom_columns');
- add_filter('manage_edit-homeslider_columns', 'shawnrisk_homeslider_edit_columns');
- function create_homeslider() {
- register_post_type( 'homeslider',
- array(
- 'labels' => array(
- 'name' => _x('Home Slider', 'post type general name'),
- 'singular_name' => _x('Home Slider', 'post type singular name'),
- 'add_new' => _x('Add New', 'Home Slider'),
- 'add_new_item' => __('Add New Home Slider'),
- 'edit_item' => __('Edit Home Slider'),
- 'new_item' => __('New Home Slider'),
- 'view_item' => __('View Home Slider'),
- 'search_items' => __('Search Home Slider'),
- 'not_found' => __('No Home Sliders found'),
- 'not_found_in_trash' => __('No Home Sliders found in Trash'),
- 'parent_item_colon' => ''
- ),
- 'public' => true,
- 'supports' => array( 'title', 'editor', 'custom-fields', 'revisions', 'excerpt' ),
- )
- );
- register_taxonomy("Template", array("homeslider"), array("hierarchical" => true, "label" => "Templates", "singular_label" => "Template", "show_ui" => true, "rewrite" => true));
- }
- function shawnrisk_add_meta_boxes() {
- add_meta_box("actioncall_meta", "Action Call", "shawnrisk_actioncall_meta", "homeslider", "normal", "low");
- add_meta_box("buttontype_meta", "Button Type", "shawnrisk_buttontype_meta", "homeslider", "normal", "low");
- add_meta_box("tagline_meta", "Tag Line", "shawnrisk_tagline_meta", "homeslider", "normal", "low");
- }
- function shawnrisk_actioncall_meta() {
- global $post;
- $custom = get_post_custom($post->ID);
- $actioncalls = $custom["actioncalls"][0];
- echo '<p><label>Action Call</label><br /> <textarea cols="50" rows="5" name="actioncalls">' . esc_textarea( $actioncalls ) . '</textarea></p>';
- }
- function shawnrisk_buttontype_meta() {
- global $post;
- $custom = get_post_custom($post->ID);
- $buttontypes = $custom["buttontypes"][0];
- echo '<p><label>Button Type</label><br /> <input type="radio" value="View" name="buttontypes" />View <input type="radio" value="Shop" name="buttontypes" />Shop</p>';
- }
- function shawnrisk_tagline_meta() {
- global $post;
- $custom = get_post_custom($post->ID);
- $taglines = $custom["taglines"][0];
- echo '<p><label>Tag Line</label><br /> <textarea cols="50" rows="5" name="taglines">' . esc_textarea( $taglines ) . '</textarea></p>';
- }
- function shawnrisk_save_homeslider_details() {
- global $post;
- // You need some validation here
- // See http://codex.wordpress.org/Data_Validation
- update_post_meta($post->ID, "actioncalls", $_POST["actioncalls"]);
- update_post_meta($post->ID, "buttontypes", $_POST["buttontypes"]);
- update_post_meta($post->ID, "taglines", $_POST["taglines"]);
- }
- function shawnrisk_homeslider_edit_columns($columns) {
- $columns = array(
- "cb" => "<input type="checkbox" />",
- "title" => "Home Slider Title",
- "description" => "Description",
- "date" => "Date Posted",
- "tagline" => "Tag Line",
- );
- return $columns;
- }
- function shawnrisk_homeslider_custom_columns($columns) {
- global $post;
- switch($columns) {
- case "description":
- the_excerpt();
- break;
- case "date":
- echo the_time('jS F Y');
- break;
- case "tagline":
- echo $custom["taglines"][0];
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement