Don't like ads? PRO users don't see any ads ;-)
Guest

Custom Post Type with Default Category and Tags

By: UrbanAggie on May 7th, 2012  |  syntax: PHP  |  size: 1.59 KB  |  hits: 48  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Hook into the init action and call create_post_type when it fires
  2.    add_action( 'init', 'create_post_type' );
  3.        
  4.    function create_post_type() {
  5.         $labels = array( // define the name of the custom post type
  6.         'name'  => _x('Articles','custom post type general name'),
  7.         'singular_name' => _x('Article','custom post type singular name' ),
  8.         'add_new'       => _x('Add New','article'),
  9.         'add_new_item'  => __('Add New Article'),
  10.         'edit_item'     => __('Edit Article'),
  11.         'new_item'      => __('New Article'),
  12.         'all_items'     => __('All Articles'),
  13.         'view_item'     => __('View Article'),
  14.         'search_items'  => __('Search Articles'),
  15.         'not_found'     => __('No articles found'),
  16.         'not_found_in_trash'    => __('No articles found in Trash'),
  17.         'parent_item_colon'     => '',
  18.         'menu_name'     => 'Articles'
  19.         );
  20.                                
  21.         $args = array(
  22.         'labels'        => $labels,
  23.         'public'        => true,  // true=show the post type in the admin section
  24.         'publicly_queryable'    => true,  
  25.         'show_ui'       => true,  // generate a default admin user interface
  26.         'show_in_menu'  => true,  // display as a top-level menu item
  27.         'query_var'     => true,
  28.         'rewrite'       => array('slug' => 'articles'),  // rewrite the url to make it pretty
  29.         'menu_position' => 5,     // show below Posts but above Media
  30.         'supports'      => array( 'title', 'editor', 'comments', 'revisions', 'author', 'excerpt', 'custom-fields', 'thumbnail' ),
  31.         'has_archive'   => true,
  32.         'taxonomies'    => array('category', 'post_tag'),  // just use default categories and tags
  33.         'show_in_nav_menus' => true // makes this post type available for selection in navigation menus
  34.         );
  35.                
  36.                
  37.         register_post_type('tnt_articles', $args);
  38.                
  39.   }