Skip to content

Instantly share code, notes, and snippets.

@aaroneaton
Created August 17, 2012 21:54
Show Gist options
  • Save aaroneaton/3383031 to your computer and use it in GitHub Desktop.
Save aaroneaton/3383031 to your computer and use it in GitHub Desktop.
WP:Post type and taxonomy registration
<?php
/*
Plugin Name: AgriLife Publications
Description: Publications Custom Post Type
Version: 1.0
Author: TAMU CIS (not agrilife)
License: GPL2
*/
// Begin - Publication Custom Post Type
add_action( 'init', 'publication_post_type' );
function publication_post_type() {
$labels = array(
'name' => _x('Publications', 'post type general name'),
'singular_name' => _x('Publication', 'post type singular name'),
'add_new' => _x('Add New Publication', 'equipment item'),
'add_new_item' => __('Add New Publication'),
'edit_item' => __('Edit Publication'),
'new_item' => __('New Publication'),
'view_item' => __('View Publication'),
'search_items' => __('Search Publications'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'menu_icon' => '',
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 5,
'supports' => array('title', 'editor', 'thumbnail', 'revisions')
);
register_post_type('publications', $args);
}
// End - Publications Custom Post Type
// Begin - Publication Taxonomies
add_action('init', 'publication_year_taxonomy');
function publication_year_taxonomy() {
$labels = array(
'name' => _x('Year', 'taxonomy general name'),
'singular_name' => _x('Year', 'taxonomy singular name'),
'search_items' => __('Search Years'),
'all_items' => __('All Years'),
'parent_item' => __('Parent Year'),
'parent_item_colon' => __('Parent Year:'),
'edit_item' => __('Edit Year'),
'update_item' => __('Update Year'),
'add_new_item' => __('Add New Year'),
'new_item_name' => __('New Year Name'),
'menu_name' => __('Year')
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'year' )
);
register_taxonomy('year', array('publications'), $args);
}
// End - Publication Taxonomies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment