_x( 'Events', 'Taxonomy General Name', 'text_domain' ), 'singular_name' => _x( 'Event', 'Taxonomy Singular Name', 'text_domain' ), 'menu_name' => __( 'Events', 'text_domain' ), 'all_items' => __( 'All Events', 'text_domain' ), 'parent_item' => __( 'Parent Event', 'text_domain' ), 'parent_item_colon' => __( 'Parent Event:', 'text_domain' ), 'new_item_name' => __( 'New Event Name', 'text_domain' ), 'add_new_item' => __( 'Add New Event', 'text_domain' ), 'edit_item' => __( 'Edit Event', 'text_domain' ), 'update_item' => __( 'Update Event', 'text_domain' ), 'view_item' => __( 'View Event', 'text_domain' ), 'separate_items_with_commas' => __( 'Separate Events with commas', 'text_domain' ), 'add_or_remove_items' => __( 'Add or remove Events ', 'text_domain' ), 'choose_from_most_used' => __( 'Choose from the most used', 'text_domain' ), 'popular_items' => __( 'Popular Events', 'text_domain' ), 'search_items' => __( 'Search Events', 'text_domain' ), 'not_found' => __( 'Not Found', 'text_domain' ), 'items_list' => __( 'Events list', 'text_domain' ), 'items_list_navigation' => __( 'Events list navigation', 'text_domain' ), ); $args = array( 'labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => true, ); register_taxonomy( 'event', array( 'timeline' ), $args ); } add_action( 'init', 'custom_taxonomy_event', 0 ); } /**************** ********** Register new custom post type "Timeline" ****************/ if ( ! function_exists('custom_post_type_timeline') ) { // Register Custom Post Type function custom_post_type_timeline() { $labels = array( 'name' => _x( 'Timelines', 'Post Type General Name', 'text_domain' ), 'singular_name' => _x( 'Timeline', 'Post Type Singular Name', 'text_domain' ), 'menu_name' => __( 'Timeline', 'text_domain' ), 'name_admin_bar' => __( 'Timeline', 'text_domain' ), 'parent_item_colon' => __( 'Parent Timeline:', 'text_domain' ), 'all_items' => __( 'All Timelines', 'text_domain' ), 'add_new_item' => __( 'Add New Timeline', 'text_domain' ), 'add_new' => __( 'Add New', 'text_domain' ), 'new_item' => __( 'Timeline', 'text_domain' ), 'edit_item' => __( 'Edit Timeline', 'text_domain' ), 'update_item' => __( 'Update Timeline', 'text_domain' ), 'view_item' => __( 'View Timeline', 'text_domain' ), 'search_items' => __( 'Search Timeline', 'text_domain' ), 'not_found' => __( 'Timeline Not found', 'text_domain' ), 'not_found_in_trash' => __( 'Timeline Not found in Trash', 'text_domain' ), 'items_list' => __( 'Timelines list', 'text_domain' ), 'items_list_navigation' => __( 'Timelines list navigation', 'text_domain' ), 'filter_items_list' => __( 'Filter Timelines list', 'text_domain' ), ); $args = array( 'label' => __( 'Timeline', 'text_domain' ), 'description' => __( 'Every post will become to slide show or slider', 'text_domain' ), 'labels' => $labels, 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments' ), 'taxonomies' => array( 'event' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 12, 'menu_icon' => 'dashicons-chart-line', 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => false, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'post', ); register_post_type( 'timeline', $args ); } add_action( 'init', 'custom_post_type_timeline', 0 ); } /* Add custom fields into main block for timeline post type */ function timeline_add_custom_box() { $screens = array( 'timeline' ); foreach ( $screens as $screen ) add_meta_box( 'timeline', 'Timeline', 'timeline_meta_box_callback', $screen, 'normal', 'high' ); } add_action('add_meta_boxes', 'timeline_add_custom_box'); /* HTML code of our input field */ function timeline_meta_box_callback() { global $post; // Use "nonce" for verification wp_nonce_field( plugin_basename(__FILE__), 'timeline_noncename' ); $image_id = get_post_meta( $post->ID, 'timeline', true ); // Form input field markup echo ' '; echo ''; } /* Save data when post is saved */ function timeline_save_postdata( $post_id ) { // Check "nonce" of our page, because "save_post" could be called from another place. if (isset($_POST['timeline_noncename'])) { if (!wp_verify_nonce($_POST['timeline_noncename'], plugin_basename(__FILE__))) { return $post_id; } } // Check, if autosave -> do noting with data of our form. if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // Check user capabilities to edit post data. if ( isset($_POST['timeline']) && $_POST['timeline'] == 'timeline' && ! current_user_can( 'edit_post', $post_id ) ) { return $post_id; } elseif( !current_user_can( 'edit_post', $post_id ) ) { return $post_id; } // Be sure that field is installed. if (!isset($_POST['timeline_new_field'])) { return; } // OK. Now, we must find and save data // Clear the value of input field . $my_data = sanitize_text_field( $_POST['timeline_new_field'] ); // Update data in data base update_post_meta( $post_id, 'timeline', $my_data ); } add_action( 'save_post', 'timeline_save_postdata' ); /** * Used in the widgets by appending the registered image sizes * * @since 1.0 */ if (!function_exists('ang_get_thumbnail_sizes')){ function ang_get_thumbnail_sizes() { global $_wp_additional_image_sizes; $sizes = array(); foreach( get_intermediate_image_sizes() as $s ) { $sizes[ $s ] = array( 0, 0 ); if( in_array( $s, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) { $sizes[ $s ][0] = get_option( $s . '_size_w' ); $sizes[ $s ][1] = get_option( $s . '_size_h' ); $sizes[ $s ]['crop'] = get_option( $s . '_crop' ) ? 'crop' : 'no-crop'; } else { if( isset( $_wp_additional_image_sizes ) && isset( $_wp_additional_image_sizes[ $s ] ) ) { $sizes[ $s ] = array( $_wp_additional_image_sizes[ $s ]['width'], $_wp_additional_image_sizes[ $s ]['height'], ); } } } return $sizes; } } /* * add theme support post thumbnails in timeline listing for admin */ add_filter('manage_edit-timeline_columns', 'timeline_listing', 5); function timeline_listing($default1) { $default1['post_thumbnails'] = 'Image'; return $default1; } //image size add_action('manage_timeline_posts_custom_column', 'timeline_custom_columns', 5, 2); function timeline_custom_columns($row_label, $id) { if ($row_label === 'post_thumbnails') : print the_post_thumbnail(array(85,85)); endif; } // sortable columns add_filter('manage_edit-timeline_sortable_columns', 'add_timeline_sortable_column'); function add_timeline_sortable_column($sortable_columns){ $sortable_columns['post_thumbnails'] = 'Image'; return $sortable_columns; } //add custom meta box start function ang_add_metabox(){ add_meta_box('before_publish', 'Reminder', 'ang_metabox_content', 'timeline', 'side', 'high'); } function ang_metabox_content() { ?>
Don't forget to publish