Last active
October 11, 2015 06:18
-
-
Save mannieschumpert/3815767 to your computer and use it in GitHub Desktop.
WordPress Taxonomy Snippet for Sublime Text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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> |
This is very useful Mannie - Thanks for the share!
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
Usage
FUNCTIONinstances will be selected. Enter your desired function suffix.SINGULARinstances will be selected. Enter the singular version of your taxonomy name.PLURALinstances will be selected. You know what to do.