Paste the above code into your functions.php
file. You may find the Custom Post Type Permalinks plugin useful for customizing permalinks on a per-post-type basis.
Last active
August 29, 2015 14:02
-
-
Save galengidman/526f4d32bd0bd38ccc89 to your computer and use it in GitHub Desktop.
WordPress post type and taxonomy setup for a knowledge base.
This file contains 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
<?php | |
add_action( 'init', 'kb_register_post_types' ); | |
function kb_register_post_types() { | |
register_post_type( 'kb_article', array( | |
'labels' => array( | |
'name' => 'Articles', | |
'singular_name' => 'Article', | |
'menu_name' => 'Knowledge Base', | |
'name_admin_bar' => 'KB Article', | |
'all_items' => 'Articles', | |
'add_new_item' => 'Add New Article', | |
'edit_item' => 'Edit Article', | |
'new_item' => 'New Article', | |
'view_item' => 'View Article', | |
'search_items' => 'Search Articles', | |
'not_found' => 'No articles found.', | |
'not_found_in_trash' => 'No articles found in trash.' | |
), | |
'public' => true, | |
'menu_icon' => 'dashicons-sos', | |
'rewrite' => array( | |
'slug' => 'kb', | |
'with_front' => false | |
), | |
'has_archive' => true, | |
'supports' => array( | |
'title', | |
'editor', | |
'revisions' | |
), | |
) ); | |
} | |
add_action( 'init', 'kb_register_taxonomies' ); | |
function kb_register_taxonomies() { | |
register_taxonomy( 'kb_category', 'kb_article', array( | |
'hierarchical' => true, | |
'rewrite' => array( | |
'slug' => 'category', | |
'with_front' => false, | |
) | |
) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment