Skip to content

Instantly share code, notes, and snippets.

@dtbaker
Created April 4, 2013 04:39
Show Gist options
  • Save dtbaker/5307869 to your computer and use it in GitHub Desktop.
Save dtbaker/5307869 to your computer and use it in GitHub Desktop.
Register wiki custom post type
public function register_custom_post_type() {
$labels = array(
'name' => 'Wiki Pages',
'singular_name' => 'Wiki Page',
'menu_name' => 'Wiki Pages',
'parent_item_colon' => 'Parent Wiki Page:',
'all_items' => 'All Wiki Pages',
'view_item' => 'View Wiki Page',
'add_new_item' => 'Add New Wiki Page',
'add_new' => 'New Wiki Page',
'edit_item' => 'Edit Wiki Page',
'update_item' => 'Update Wiki Page',
'search_items' => 'Search wiki pages',
'not_found' => 'No wiki pages found',
'not_found_in_trash' => 'No wiki pages found in Trash',
);
$rewrite = array(
// 'slug' => 'wiki', //'support/documentation-wiki', // todo: option this out.
'slug' => 'support/documentation-wiki', // todo: option this out.
'with_front' => false,
'pages' => true,
'feeds' => true,
);
$capabilities = array(
'edit_post' => 'edit_wiki_page',
'read_post' => 'read_wiki_page',
'delete_post' => 'delete_wiki_page',
'edit_posts' => 'edit_wiki_pages',
'edit_others_posts' => 'edit_others_wiki_pages',
'publish_posts' => 'publish_wiki_pages',
//'read_private_posts' => 'read_private_wiki_pages',
'delete_posts' => 'delete_wiki_pages',
//'delete_private_posts' => 'delete_private_wiki_pages',
'delete_published_posts' => 'delete_published_wiki_pages',
'delete_others_posts' => 'delete_others_wiki_pages',
//'edit_private_posts' => 'edit_private_wiki_pages',
'edit_published_posts' => 'edit_published_wiki_pages',
);
$args = array(
'label' => 'wiki_page',
'description' => 'Wiki pages',
'labels' => $labels,
'supports' => array( 'title', 'editor', 'revisions', 'comments', 'page-attributes'),
'taxonomies' => array( ),//'category', 'post_tag'
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 25,
'menu_icon' => '',
'can_export' => true,
'has_archive' => false, // important for our support/documentation-wiki slug
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capabilities' => $capabilities,
);
register_post_type( 'wiki_page', $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment