Make WordPress Core


Ignore:
Timestamp:
03/23/2008 05:02:11 PM (17 years ago)
Author:
ryan
Message:

Taxonomy queries and urls. Props andy. see #6357

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r7481 r7491  
    146146 */
    147147function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
    148     global $wp_taxonomies;
     148    global $wp_taxonomies, $wp_rewrite;
    149149
    150150    $defaults = array('hierarchical' => false, 'update_count_callback' => '');
    151151    $args = wp_parse_args($args, $defaults);
     152
     153    if ( !empty( $args['rewrite'] ) ) {
     154        if ( !is_array($args['rewrite']) )
     155            $args['rewrite'] = array();
     156        if ( !isset($args['rewrite']['slug']) )
     157            $args['rewrite']['slug'] = sanitize_title_with_dashes($taxonomy);
     158        $wp_rewrite->add_rewrite_tag("%$taxonomy%", '([^/]+)', "taxonomy=$taxonomy&term=");
     159        $wp_rewrite->add_permastruct("{$args['rewrite']['slug']}/%$taxonomy%");
     160    }
    152161
    153162    $args['name'] = $taxonomy;
Note: See TracChangeset for help on using the changeset viewer.