Skip to content

Instantly share code, notes, and snippets.

@mannieschumpert
Last active October 11, 2015 06:18
Show Gist options
  • Save mannieschumpert/3815767 to your computer and use it in GitHub Desktop.
Save mannieschumpert/3815767 to your computer and use it in GitHub Desktop.
WordPress Taxonomy Snippet for Sublime Text
<snippet>
<content><![CDATA[
// Create taxonomy
add_action( 'init', 'create_${1:FUNCTION}' );
function create_${1:FUNCTION}() {
\$labels = array(
'name' => _x( '${3:PLURAL}', 'taxonomy general name' ),
'singular_name' => _x( '${2:SINGULAR}', 'taxonomy singular name' ),
'search_items' => __( 'Search ${3:PLURAL}' ),
'all_items' => __( 'All ${3:PLURAL}' ),
'parent_item' => __( 'Parent ${2:SINGULAR}' ),
'parent_item_colon' => __( 'Parent ${2:SINGULAR}:' ),
'edit_item' => __( 'Edit ${2:SINGULAR}' ),
'update_item' => __( 'Update ${2:SINGULAR}' ),
'add_new_item' => __( 'Add New ${2:SINGULAR}' ),
'new_item_name' => __( 'New ${2:SINGULAR} Name' ),
);
register_taxonomy('${3:PLURAL}','${4:POST-TYPE}',array(
'hierarchical' => true, // false for tags
'labels' => \$labels
));
}
]]></content>
<tabTrigger>wptax</tabTrigger>
<scope>source.php</scope>
</snippet>
@mannieschumpert
Copy link
Author

I just fixed something that's bugged me for a while: the $labels needed to be escaped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment