Skip to content

Instantly share code, notes, and snippets.

@MrQwest
Created August 3, 2015 19:58
Show Gist options
  • Save MrQwest/83ec3019c85bcc77dcda to your computer and use it in GitHub Desktop.
Save MrQwest/83ec3019c85bcc77dcda to your computer and use it in GitHub Desktop.
Eurgh... Custom Post Types & Taxonomies...
register_taxonomy(
'service_types',
'service',
array(
'hierarchical' => true,
'label' => __('Service Types'),
'rewrite' => array('hierarchical' => true, 'slug' => 'services', 'with_front' => false),
)
);
// Register Custom Post Type
function custom_post_type() {
// Location pages
$labels = array(
'name' => _x( 'Location', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Location Entry', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Location Entry', 'text_domain' ),
'parent_item_colon' => __( 'Parent Item:', 'text_domain' ),
'all_items' => __( 'All Items', 'text_domain' ),
'view_item' => __( 'View Item', 'text_domain' ),
'add_new_item' => __( 'Add New Item', 'text_domain' ),
'add_new' => __( 'Add New', 'text_domain' ),
'edit_item' => __( 'Edit Item', 'text_domain' ),
'update_item' => __( 'Update Item', 'text_domain' ),
'search_items' => __( 'Search Item', 'text_domain' ),
'not_found' => __( 'Not found', 'text_domain' ),
'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ),
);
$args = array(
'label' => __( 'post_type', 'text_domain' ),
'description' => __( 'Post Type Description', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title' ),
'taxonomies' => array( 'service_types', 'category', 'post_tag', 'services' ),
'hierarchical' => true,
'rewrite' => array( 'slug' => 'services', 'with_front' => false ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => '',
'can_export' => true,
'has_archive' => 'services',
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'location', $args );
}
add_action( 'init', 'custom_post_type', 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment