Skip to content

Instantly share code, notes, and snippets.

@farnsco
Created March 9, 2013 19:53
Show Gist options
  • Save farnsco/5125500 to your computer and use it in GitHub Desktop.
Save farnsco/5125500 to your computer and use it in GitHub Desktop.
Wordpress: Register Custom Post Type
// Registering Custom Post Type for Replace_names
function custom_type_Replace_names() {
$labels = array(
'name' => 'Replace_names',
'singular_name' => 'Replace_name',
'add_new' => 'Add Replace_name',
'add_new_item' => 'Add New',
'edit_item' => 'Edit Replace_name',
'new_item' => 'New Replace_name',
'all_items' => 'All Replace_names',
'view_item' => 'View Replace_name',
'search_items' => 'Search Replace_names',
'not_found' => 'The bar is dry (no coctails found)',
'not_found_in_trash' => 'No Replace_names found in the sink (trash)',
'parent_item_colon' => '',
'menu_name' => 'Replace_names'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'Replace_names' ),
'capability_type' => 'page',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => 6, // 5 - below Posts, 10 - below Media, 15 - below Links, 20 - below Pages, 25 - below comments, 60 - below first separator, 65 - below Plugins, 70 - below Users, 75 - below Tools, 80 - below Settings, 100 - below second separator
'menu_icon' => '/wp-content/themes/macemeadworks-ind-v1.0/img/icn-person.png', // OPTIONAL
'supports' => array( 'title', 'editor', 'thumbnail')
);
register_post_type( 'Replace_names', $args );
}
add_action( 'init', 'custom_type_Replace_names' );
// Adding custom messaging for Replace_names
function custom_type_Replace_names_updated_messages( $messages ) {
global $post, $post_ID;
$messages['custom_type_Replace_names'] = array(
0 => '', // Unused. Messages start at index 1.
1 => sprintf( __('Replace_name updated. <a href="%s">View Replace_name</a>', 'your_text_domain'), esc_url( get_permalink($post_ID) ) ),
2 => __('Custom field updated.', 'your_text_domain'),
3 => __('Custom field deleted.', 'your_text_domain'),
4 => __('Replace_name updated.', 'your_text_domain'),
/* translators: %s: date and time of the revision */
5 => isset($_GET['revision']) ? sprintf( __('Replace_name restored to revision from %s', 'your_text_domain'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf( __('Replace_name published. <a href="%s">View Replace_name</a>', 'your_text_domain'), esc_url( get_permalink($post_ID) ) ),
7 => __('Replace_name saved.', 'your_text_domain'),
8 => sprintf( __('Replace_name submitted. <a target="_blank" href="%s">Preview Replace_name</a>', 'your_text_domain'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
9 => sprintf( __('Replace_name scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview Replace_name</a>', 'your_text_domain'),
// translators: Publish box date format, see http://php.net/date
date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
10 => sprintf( __('Replace_name draft updated. <a target="_blank" href="%s">Preview Replace_name</a>', 'your_text_domain'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
);
return $messages;
}
add_filter( 'post_updated_messages', 'custom_type_Replace_names_updated_messages' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment