Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Hy guys,

I have some problems with my taxonomies... here my code:

  define('REVIEWS_SLUG', 'review');
  define('REVIEWS_CATEGORY_SLUG', 'review-category');

  function create_reviews_section(){                                    
    $labels = array(
      'name' => __('Reviews'),
      'singular_name' => __('review'),
      'add_new' => __('Add New'),
      'add_new_item' => __('Add New Review'),
      'edit' => __('Edit'),
      'edit_item' => __('Edit Review'),
      'new_item' => __('New Review'),
      'view' => __('View'),
      'view_item' => __('View Review'),
      'search_items' => __('Search Reviews'),
      'not_found' => __('No reviews found'),
      'not_found_in_trash' => __('No reviews found in Trash'),
    );

    register_post_type('reviews', array(
            'labels' => $labels,
      'description' => __('Reviews Section'),
            'public' => true,
            'show_ui' => true,
            'publicly_queryable' => true,
            'exclude_from_search' => false,
            'supports' => array('title', 'editor', 'custom-fields', 'excerpt', 'comments', 'author'),
            'rewrite' => array('slug' => REVIEWS_SLUG, 'with_front' => true),
            'query_var' => false,
      'taxonomies' => array('review-category')      
          )
      );    
  }

  function create_review_category(){ 
    $labels = array(
      'name' => _x('Review Categories', 'Review Categories'),
      'singular_name' => _x('Review Category', 'Review Category'),
      'search_items' =>  __('Search Review Categories'),
      'popular_items' => __('Popular Review Categories'),
      'all_items' => __('All Review Categories'),
      'edit_item' => __('Edit Review Category'), 
      'update_item' => __('Update Review Category'),
      'add_new_item' => __('Add New Review Category'),
      'new_item_name' => __('New Review Category'),
      'separate_items_with_commas' => __('Separate review categories with commas'),
      'add_or_remove_items' => __('Add or remove review categories'),
      'choose_from_most_used' => __('Choose from the most used review categories'),
      'menu_name' => __('Categories')
    ); 

    register_taxonomy('review-category', array('reviews'), array(
      'hierarchical' => true,
      'labels' => $labels,
      'show_ui' => true,
      'query_var' => true,
      'rewrite' => array('slug' => REVIEWS_CATEGORY_SLUG),
    ));

First problem is that wordpress doesn't recognize this taxonomy as hierarhical. For example when I generate a dropdown with this taxonomy and depth="1", return all taxonomies (parents & childs).

Second problem: when I'm trying to insert a new term (with wp_insert_term) is telling me that the taxonomy it's not valid.

Third problem: I thought that child taxonomy url will be like: domain.com/review-category/parent-taxonomy/child-taxonomy/ but in my case is: domain.com/review-category/child-taxonomy/. How I can modify the url to something like that ?

Thanks in advance ;)

LE:

  add_action('init', 'create_reviews_section');
  add_action('init', 'create_review_category', 0);
$args = array(
                                          'show_option_none' => 'Choose make',
                                          'hide_empty' => 0,
                                          'name' => 'vehicle_category',
                                          'id' => 'vehicle_category',
                                          'taxonomy' => 'review-category',
                                          'hierarchical' => 0,
                                          'class' => 'maxw',
                                          'depth' => 1
                                          ); 
                         wp_dropdown_categories( $args );
share|improve this question
    
any idea about my problem ? –  George Jipa Jul 14 '11 at 11:20
    
Couple things...can you post the code you use to generate your dropdown and, what hook(s) are you using to call create_review_category? –  tollmanz Jul 14 '11 at 19:31
    
@tollmanz: done! –  George Jipa Jul 14 '11 at 19:36
    
Can you show the function that inserts the term and what action calls it? –  tollmanz Jul 14 '11 at 19:49
    
Second problem solved! It was just a typo problem :D –  George Jipa Jul 14 '11 at 20:03
add comment

1 Answer

up vote 0 down vote accepted

For question one, reading the following from the codex makes me think you need to change hierarchical to 1:

depth (integer) (optional) The max depth. This is ignore unless hierarchical is set to true. Default: 0/False

hierarchical (boolean) (optional) Display all categories (0/False) or display categories (1/True) to a depth of 'depth'. Default: 0/False

share|improve this answer
    
yeah... you're right! I was a little bit sleepy when I've read the documentation. thx –  George Jipa Jul 14 '11 at 19:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.