Definition:
function register_taxonomy( $taxonomy, $object_type, $args = array() {}
Create or modify a taxonomy object. Do not use before init.
A simple function for creating or modifying a taxonomy object based on the parameters given. The function will accept an array (third optional parameter), along with strings for the taxonomy name and another string for the object type.
Parameters
- string $taxonomy: Name of taxonomy object
- array|string $object_type: Name of the object type for the taxonomy object.
- array|string $args: See above description for the two keys values.
Source code
function register_taxonomy( $taxonomy, $object_type, $args = array() ) { global $wp_taxonomies, $wp_rewrite, $wp; if ( ! is_array($wp_taxonomies) ) $wp_taxonomies = array(); $defaults = array( 'hierarchical' => false, 'update_count_callback' => '', 'rewrite' => true, 'query_var' => $taxonomy, 'public' => true, 'show_ui' => null, 'show_tagcloud' => null, '_builtin' => false, 'labels' => array(), 'capabilities' => array(), 'show_in_nav_menus' => null, ); $args = wp_parse_args($args, $defaults); if ( false !== $args['query_var'] && !empty($wp) ) { if ( true === $args['query_var'] ) $args['query_var'] = $taxonomy; $args['query_var'] = sanitize_title_with_dashes($args['query_var']); $wp->add_query_var($args['query_var']); } if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') ) { $args['rewrite'] = wp_parse_args($args['rewrite'], array( 'slug' => sanitize_title_with_dashes($taxonomy), 'with_front' => true, 'hierarchical' => false )); if ( $args['hierarchical'] && $args['rewrite']['hierarchical'] ) $tag = '(.+?)'; else $tag = '([^/]+)'; $wp_rewrite->add_rewrite_tag("%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term="); $wp_rewrite->add_permastruct($taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front']);
2685
No comments yet... Be the first to leave a reply!