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.

I created a taxonomy called "portfolio categories" for my portfolio custom post type. They're hierarchical and supposed to be behave like categories. when i'm editing a single portfolio post... i have a metabox where i can assign the proper portfolio category. It shows all categories at all the depths.

unlimited hierarchy

but when i am on the Taxonomy page (edit-tags.php?taxonomy=portfolio-cats&post_type=portfolio) then it only shows top level categories and their immediate children... and no further. so grandchild-level categories are missing even though there are portfolio pieces assigned to them.

limited hierarchy

is this default behavior? b/c i can see unlimited depths on the regular Categories page. should a hierarchical taxonomy behave the same?

/*
 * Builds the a tag taxonomies
 */

function create_portfolio_taxonomies() {
// Add new taxonomy, make it hierarchical (like categories)
  $labels = array(
    'name' => _x( 'Portfolio Categories', 'taxonomy general name' ),
    'singular_name' => _x( 'Portfolio Category', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Portfolio Categories' ),
    'all_items' => __( 'All Portfolio Categories' ),
    'parent_item' => __( 'Parent Portfolio Category' ),
    'parent_item_colon' => __( 'Parent Portfolio Category:' ),
    'edit_item' => __( 'Edit Portfolio Category' ), 
    'update_item' => __( 'Update Portfolio Category' ),
    'add_new_item' => __( 'Add New Portfolio Category' ),
    'new_item_name' => __( 'New Portfolio Category Name' ),
    'menu_name' => __( 'Portfolio Categories' ),
  );    

    register_taxonomy( 'portfolio-cats', array('portfolio'), 
        array( 
            'hierarchical' => true, 
            'labels' => $labels, 
            'rewrite' => array( 'slug' => 'portfolio','with_front' => true, 'hierarchical' => true  ),
        ) );

    //preset some categories
    my_add_term($postID,'portfolio-cats','Print');  
    my_add_term($postID,'portfolio-cats','Digital');

}
add_action( 'init', 'create_portfolio_taxonomies', 0 );



function my_add_term($id, $tax, $term) {

    $term_id = intval(term_exists($term));
    if (!$term_id) {
        $term_id = wp_insert_term($term, $tax);
        $term_id = $term_id['term_id'];
    }
    $result =  wp_set_object_terms($id, array($term_id), $tax, FALSE);

    return $result;
}
share|improve this question
    
What version of WordPress are you using? –  Brian Fegter Dec 30 '11 at 13:17
1  
I created a custom taxonomy in WP 3.3 and could not replicate the issue you're having. 3-3.me/rG59 Try disabling plugins and check your args for registering the taxonomy. –  Brian Fegter Dec 30 '11 at 13:20
    
Can you post your code (or a link to it in pastebin or equivalent) for registering the taxonomy? –  tnorthcutt Jan 9 '12 at 17:35
    
wow, had to go dig my old code out. that content is long gone from my local install, but i recreated some portfolio categories quickly and at first they appeared correctly so i thought 3.3.1 had fixed this for me. but when i refreshed the edit-tags.php page i lost all the hierarchy. –  helgatheviking Jan 10 '12 at 23:50
add comment

1 Answer

up vote 1 down vote accepted

Pretty bizarre issue. I popped in that same code and successfully replicated the issue. I then removed the calls to my_add_term, reset my permalinks (not sure if this helped or not but worth mentioning that I did it), added an item, reloaded, and they all showed up in heirarchy as expected.

In the calls to my_add_term, you're passing $postID but that isn't defined, so I'm guessing that's where the issue is coming from. Bottom line, you don't need to define Print and Digital as your base categories with every single page load, so that code can reasonably be removed. Let me know if this fixes it for you!

Cheers~

share|improve this answer
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.