Skip to content

Instantly share code, notes, and snippets.

@oterox
Created September 25, 2012 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oterox/3784068 to your computer and use it in GitHub Desktop.
Save oterox/3784068 to your computer and use it in GitHub Desktop.
Sublime Text Custom Post Type Snippet
<snippet>
<content><![CDATA[
add_action( 'init', 'register_cpt_${1:test}' );
function register_cpt_${1:test}() {
\$labels = array(
'name' => _x( '${2:Tests}', '${1:test}' ),
'singular_name' => _x( '${3:Test}', '${1:test}' ),
'add_new' => _x( 'Add New ${3:Test}', '${1:test}' ),
'add_new_item' => _x( 'Add New ${3:Test}', '${1:test}' ),
'edit_item' => _x( 'Edit ${3:Test}', '${1:test}' ),
'new_item' => _x( 'New ${3:Test}', '${1:test}' ),
'view_item' => _x( 'View ${3:Test}', '${1:test}' ),
'search_items' => _x( 'Search ${2:Tests}', '${1:test}' ),
'not_found' => _x( 'No ${2:Tests} found', '${1:test}' ),
'not_found_in_trash' => _x( 'No ${2:Tests} found in Trash', '${1:test}' ),
'parent_item_colon' => _x( 'Parent ${3:Test}:', '${1:test}' ),
'menu_name' => _x( '${2:Tests}', '${1:test}' ),
);
\$args = array(
'labels' => \$labels,
'hierarchical' => true,
'description' => 'description',
'taxonomies' => array( 'category' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
//'menu_icon' => '',
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post',
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'custom-fields', 'trackbacks', 'comments', 'revisions', 'page-attributes', 'post-formats' ),
);
register_post_type( '${1:test}', \$args );
}]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>cpt</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- Optional: Description to show in the menu -->
<description>Register Custom Post Type Wordpress</description>
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment