Skip to content

Instantly share code, notes, and snippets.

@timiwahalahti
Last active April 6, 2016 12:01
Show Gist options
  • Save timiwahalahti/5ecf08a197848513fe8388ef61189150 to your computer and use it in GitHub Desktop.
Save timiwahalahti/5ecf08a197848513fe8388ef61189150 to your computer and use it in GitHub Desktop.
Atom snippet for register_post_type with labels and arguments
'.source.php':
'Register CPT with args':
'prefix': 'register_post_type'
'body': """
$labels = array(
'name' => _x( 'Examples', 'post type general name', 'textdomain' ),
'singular_name' => _x( 'Example', 'post type singular name', 'textdomain' ),
'menu_name' => _x( 'Examples', 'admin menu', 'textdomain' ),
'name_admin_bar' => _x( 'Example', 'add new on admin bar', 'textdomain' ),
'add_new' => _x( 'Add New', 'example', 'textdomain' ),
'add_new_item' => __( 'Add New Example', 'textdomain' ),
'new_item' => __( 'New Example', 'textdomain' ),
'edit_item' => __( 'Edit Example', 'textdomain' ),
'view_item' => __( 'View Example', 'textdomain' ),
'all_items' => __( 'All Examples', 'textdomain' ),
'search_items' => __( 'Search Examples', 'textdomain' ),
'parent_item_colon' => __( 'Parent Examples:', 'textdomain' ),
'not_found' => __( 'No examples found.', 'textdomain' ),
'not_found_in_trash' => __( 'No examples found in Trash.', 'textdomain' )
);
$args = array(
'labels' => $labels,
'description' => __( 'Description.', 'textdomain' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'example' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'menu_icon' => null,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
);
register_post_type( 'example', $args );
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment