Taxonomy queries and urls. Props andy. see #6357

git-svn-id: https://develop.svn.wordpress.org/trunk@7491 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2008-03-23 17:02:11 +00:00
parent 2377fb7ce0
commit cbfb5d78b5
9 changed files with 148 additions and 86 deletions
+10 -1
View File
@@ -145,11 +145,20 @@ function is_taxonomy_hierarchical($taxonomy) {
* @param array|string $args See above description for the two keys values.
*/
function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
global $wp_taxonomies;
global $wp_taxonomies, $wp_rewrite;
$defaults = array('hierarchical' => false, 'update_count_callback' => '');
$args = wp_parse_args($args, $defaults);
if ( !empty( $args['rewrite'] ) ) {
if ( !is_array($args['rewrite']) )
$args['rewrite'] = array();
if ( !isset($args['rewrite']['slug']) )
$args['rewrite']['slug'] = sanitize_title_with_dashes($taxonomy);
$wp_rewrite->add_rewrite_tag("%$taxonomy%", '([^/]+)', "taxonomy=$taxonomy&term=");
$wp_rewrite->add_permastruct("{$args['rewrite']['slug']}/%$taxonomy%");
}
$args['name'] = $taxonomy;
$args['object_type'] = $object_type;
$wp_taxonomies[$taxonomy] = (object) $args;