<?php register_post_type( $post_type, $args = array( 'labels' => array(), 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'capabilities' => array(), 'hierarchical' => false, 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, 'permalink_epmask' => EP_PERMALINK, 'can_export' => true, 'show_in_nav_menus' => null ) ); ?>
add_post_type_support
Description
This function adds support of certain features for a given post type(s). This means that a given area (or areas) of the edit screen will be available.
It is recommended that it is attached to the init
action hook.
Synopsis
<?php add_post_type_support( $post_type, $feature ) ?>
Usage
<?php add_post_type_support( $post_type, $feature ) ?>
Examples
Adding excerpts to Pages
You could cut & paste the following code into the functions.php file of your theme, or add it in a plugin form, to allow excerpts for Pages.
<?php add_action( 'init', 'add_excerpt_to_page_post_type' ); function add_excerpt_to_page_post_type(){ add_post_type_support( 'page', 'excerpt' ); }; ?>
Parameters
- $post_type
- (string) (required) Post type. (max. 20 characters).
Default: None - $supports
- (single string or array) (required) The post type feature to add.
Default: Nonetitle
editor
(content)author
thumbnail
(featured image) (current theme must also support post-thumbnails)excerpt
trackbacks
custom-fields
comments
(also will see comment count balloon on edit screen)revisions
(will store revisions)page-attributes
(template and menu order) (hierarchical must be true)
Source
/** * Register support of certain features for a post type. * * All features are directly associated with a functional area of the edit screen, such as the * editor or a meta box: 'title', 'editor', 'comments', 'revisions', 'trackbacks', 'author', * 'excerpt', 'page-attributes', 'thumbnail', and 'custom-fields'. * * Additionally, the 'revisions' feature dictates whether the post type will store revisions, * and the 'comments' feature dicates whether the comments count will show on the edit screen. * * @since 3.0.0 * @param string $post_type The post type for which to add the feature * @param string|array $feature the feature being added, can be an array of feature strings or a single string */ function add_post_type_support( $post_type, $feature ) { global $_wp_post_type_features; $features = (array) $feature; foreach ($features as $feature) { if ( func_num_args() == 2 ) $_wp_post_type_features[$post_type][$feature] = true; else $_wp_post_type_features[$post_type][$feature] = array_slice( func_get_args(), 2 ); } }
Related
register_post_type
By the Web Warlock, Thursday, 24/Jun/2010 10:06