- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
関数リファレンス/register post type
提供: WordPress Codex 日本語版
< 関数リファレンス
2010年4月10日 (土) 23:41時点におけるBono (トーク | 投稿記録)による版 (en:Function Reference/register_post_type 14:38, 10 April 2010 Bono 版を翻訳用にコピー)
このページはラフドラフトで、まだ内容の検証が済んでいません。情報が間違っていたり書き直されることがあります。
執筆中のため、執筆者の許可なく編集しないでください。
目次
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) (必須) Post type.
- 初期値: なし
- $args
- (array) (optional) An array of arguments.
- 初期値: なし
$args
Known Parameters for $args are:
- label
- (string) (optional) A plural descriptive name for the post type marked for translation.
- 初期値: $post_type
- singular_label
- (string) (optional) A singular descriptive name for the post type marked for translation.
- 初期値: $label
- description
- (string) (optional) A short descriptive summary of what the post type is.
- 初期値: blank
- public
- (boolean) (optional) Whether posts of this type should be shown in the admin UI.
- 初期値: false
- publicly_queryable
- (boolean) (optional) Whether post_type queries can be performed from the front page.
- 初期値: Whatever public is set as.
- exclude_from_search
- (boolean) (importance) Whether to exclude posts with this post type from search results.
- 初期値: true if the type is not public, false if the type is public
- show_ui
- (boolean) (optional) Whether to generate a default UI for managing this post type.
- 初期値: if not set, defaults to value of public argument
- 'false' - do not display a user-interface for this post type
- 'true' - display a user-interface (admin panel) for this post type
- capability_type
- (string) (optional) The post type to use for checking read, edit, and delete capabilities.
- 初期値: "post"
- edit_cap
- (string) (optional) The capability that controls editing a particular object of this post type.
- 初期値: "edit_$capability_type" (edit_post).
- edit_type_cap
- (string) (optional) The capability that controls editing objects of this post type as a class.
- 初期値: "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.
- 初期値: "edit_others_ . $capability_type . s" (edit_others_posts).
- publish_others_cap
- (string) (optional) The capability that controls publishing objects of this post type.
- 初期値: "publish_ . $capability_type . s" (publish_posts).
- read_cap
- (string) (optional) The capability that controls reading a particular object of this post type.
- 初期値: "read_$capability_type" (read_post).
- delete_cap
- (string) (optional) The capability that controls deleting a particular object of this post type.
- 初期値: "delete_$capability_type" (delete_post).
- hierarchical
- (boolean) (optional) Whether the post type is hierarchical.
- 初期値: false
- supports
- (array) (optional) An alias for calling add_post_type_support() directly.
- 'title'
- 'editor' (content)
- 'author'
- 'thumbnail'
- 'excerpts'
- 'trackbacks'
- 'custom-fields'
- 'comments'
- 'revisions'
- 'page-attributes' (parent, template, and menu order)
- 初期値: なし
- 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.
- 初期値: なし
- 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().
- 初期値: なし
- menu_postition
- (string) (optional) The position in the menu order the post type should appear.
- 初期値: null - defaults to the bottom
- menu_icon
- (string) (optional) The url to the icon to be used for this menu.
- 初期値: null - defaults to the posts icon
- permalink_epmask
- (string) (optional) The url to the icon to be used for this menu.
- 初期値: EP_NONE
- rewrite
- (array) (optional) Rewrite permalinks with this format.
- 初期値: false
- 'slug' - defaults to post_type
- 'with_front' - defaults to true
- query_var
- (boolean) (optional) Name of the query var to use for this post type.
- 初期値: false
- _builtin
- (boolean) (not for general use) Whether this post type is a native or "built-in" post_type. Note: this Codex entry is for documentation - core developers recommend you don't use this when registering your own post type
- 初期値: false
- 'false' - default this is a custom post type
- 'true' - this is a built-in native post type (post, page, attachment, revision, nav_menu_item)
- __edit_link
- (boolean) (not for general use) Link to edit an entry with this post type. Note: this Codex entry is for documentation '-' core developers recommend you don't use this when registering your own post type
- 初期値:
- 'post.php?post=%d'
Example
%%%<?php
$args = array(
'label' => __('Albums'), 'singular_label' => __('Album'), 'public' => true, 'show_ui' => true, 'capability_type' => 'page', 'hierarchical' => false, 'rewrite' => true, 'query_var' => 'album', 'supports' => array('title', 'thumbnail') );
register_post_type( 'album' , $args );
?> %%%
Change Log
- Since 2.9
Source File
register_post_type() is located in wp-includes/post.php
.
Resources
- First Impressions of Custom Post Types
- Custom Post Types in WordPress 3.0
- Extending Custom Post Types in WordPress 3.0
- Custom Post Type UI Plugin - create and administer custom post types and custom taxonomies
最新英語版: WordPress Codex » Function Reference/register_post_type (最新版との差分)
Related
関数リファレンス、テンプレートタグ目次もご覧ください。