Add taxonomies arg to register_post_type() for registering built-in taxonomies for the post type. Props technosailor. see #9674
git-svn-id: http://svn.automattic.com/wordpress/trunk@12938 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d45311c9fb
commit
679a7b5b88
|
@ -709,6 +709,7 @@ function get_post_types( $args = array(), $output = 'names' ) {
|
|||
* hierarchical - Whether the post type is hierarchical. Defaults to false.
|
||||
* supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none.
|
||||
* register_meta_box_cb - 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 - An array of taxonomy identifiers that will be registered for the post type. Default is no taxonomies. Taxonomies can be registered later with register_taxonomy() or register_taxonomy_for_object_type().
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Post
|
||||
|
@ -725,7 +726,7 @@ function register_post_type($post_type, $args = array()) {
|
|||
$wp_post_types = array();
|
||||
|
||||
// Args prefixed with an underscore are reserved for internal use.
|
||||
$defaults = array('label' => false, 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, '_show' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null);
|
||||
$defaults = array('label' => false, 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, '_show' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array() );
|
||||
$args = wp_parse_args($args, $defaults);
|
||||
$args = (object) $args;
|
||||
|
||||
|
@ -789,6 +790,10 @@ function register_post_type($post_type, $args = array()) {
|
|||
|
||||
$wp_post_types[$post_type] = $args;
|
||||
|
||||
foreach ( $args->taxonomies as $taxonomy ) {
|
||||
register_taxonomy_for_object_type( $taxonomy, $post_type );
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue