Codex

Function Reference/register post type

Contents

Description

Create or modify a post type. The function will accept an array (second optional parameter), along with a string for the post type name. Do not use before init.

Usage

<?php register_post_type$post_type$args ?>

Parameters

$post_type
(string) (required) Post type.
Default: None
$args
(array) (optional) An array of arguments.
Default: None

$args

Known Parameters for $args are:

label
(string) (optional) A plural descriptive name for the post type marked for translation.
Default: $post_type
singular_label
(string) (optional) A singular descriptive name for the post type marked for translation.
Default: $label
description
(string) (optional) A short descriptive summary of what the post type is. Defaults to blank.
Default: blank.
public
(boolean) (optional) Whether posts of this type should be shown in the admin UI.
Default: false
exclude_from_search
(boolean) (importance) Whether to exclude posts with this post type from search results.
Default: true if the type is not public, false if the type is public
publicly_queryable
(boolean) (optional) Whether post_type queries can be performed from the front page.
Default: Whatever public is set as.
show_ui
(boolean) (optional) Whether to generate a default UI for managing this post type.
Default: true if the type is public, false if the type is not public.
inherit_type
(string) (optional) The post type from which to inherit the edit link and capability type.
Default: none
capability_type
(string) (optional) The post type to use for checking read, edit, and delete capabilities.
Default: "post"
edit_cap
(string) (optional) The capability that controls editing a particular object of this post type.
Default: "edit_$capability_type" (edit_post).
edit_type_cap
(string) (optional) The capability that controls editing objects of this post type as a class.
Default: "edit_ . $capability_type . s" (edit_posts).
edit_others_cap
(string) (optional) The capability that controls editing objects of this post type that are owned by other users.
Default: "edit_others_ . $capability_type . s" (edit_others_posts).
edit_others_cap
(string) (optional) The capability that controls publishing objects of this post type.
Default: "publish_ . $capability_type . s" (publish_posts).
read_cap
(string) (optional) The capability that controls reading a particular object of this post type.
Default: "read_$capability_type" (read_post).
delete_cap
(string) (optional) The capability that controls deleting a particular object of this post type.
Default: "delete_$capability_type" (delete_post).
hierarchical
(boolean) (optional) Whether the post type is hierarchical.
Default: false
supports
(array) (optional) An alias for calling add_post_type_support() directly. See $args['supports'] below. Also See add_post_type_support() for Documentation.
Default: none
register_meta_box_cb
(string) (optional) Provide a callback function that will be called when setting up the meta boxes for the edit form. Do remove_meta_box() and add_meta_box() calls in the callback.
Default: None
taxonomies
(array) (optional) An array of taxonomy identifiers that will be registered for the post type. Taxonomies can be registered later with register_taxonomy() or register_taxonomy_for_object_type().
Default: no taxonomies

$args['supports']

  • post-thumbnails
  • excerpts
  • custom-fields
  • trackbacks
  • comments
  • revisions

Example

<?php 

$supports 
= array( 'excerpts''trackbacks''custom-fields''revisions' );
$args = array (
    
'label' => __('News'),
    
'_show' => true,
    
'_edit_link' => 'post.php?post=%d',
    
'capability_type' => 'post',
    
'hierarchical' => false,
    
$supports
);
register_post_type'news' $args );

?> 

Change Log

Since 2.9

Source File

register_post_type() is located in wp-includes/post.php.

Resources