Custom Taxonomy Won't Save to Portfolio

I have custom code in my child theme’s functions.php for www.AMDi.net that adds a custom taxonomy for Posts. What I really need is custom taxonomy for Portfolio, but when I switch the ‘post’ argument in this call: “register_taxonomy(‘Devices’,array(‘post’), array(…” it does not make a custom taxonomy under portfolio like I expect it too, nothing shows where I’d expect it to.

Is there something I’m missing because I’m scratching my head on this one?

Here’s the full snippet:

//hook into the init action and call create_book_taxonomies when it fires
add_action( ‘init’, ‘create_devices_hierarchical_taxonomy’, 0 );

//create a custom taxonomy name it devices for your posts

function create_devices_hierarchical_taxonomy() {

// Add new taxonomy, make it hierarchical like categories
//first do the translations part for GUI

$labels = array(
‘name’ => _x( ‘Devices’, ‘taxonomy general name’ ),
‘singular_name’ => _x( ‘Device’, ‘taxonomy singular name’ ),
‘search_items’ => __( ‘Search Devices’ ),
‘all_items’ => __( ‘All Devices’ ),
‘parent_item’ => __( ‘Parent Device’ ),
‘parent_item_colon’ => __( ‘Parent Device:’ ),
‘edit_item’ => __( ‘Edit Device’ ),
‘update_item’ => __( ‘Update Device’ ),
‘add_new_item’ => __( ‘Add New Device’ ),
‘new_item_name’ => __( ‘New Device Name’ ),
‘menu_name’ => __( ‘Devices’ ),
);

// Now register the taxonomy

register_taxonomy(‘Devices’,array(‘post’), array(
‘hierarchical’ => true,
‘labels’ => $labels,
‘show_ui’ => true,
‘show_admin_column’ => true,
‘query_var’ => true,
‘rewrite’ => array( ‘slug’ => ‘Device’ ),
));

}

Hi Michele,

The correct code for this part…

register_taxonomy('Devices',array('post'), array(

… is …

register_taxonomy('Devices',array('x-portfolio'), array(

Actually, here’s the updated code:

//hook into the init action and call create_book_taxonomies when it fires
add_action( 'init', 'create_devices_hierarchical_taxonomy', 0 );
 
//create a custom taxonomy name it devices for your posts
 
function create_devices_hierarchical_taxonomy() {
 
// Add new taxonomy, make it hierarchical like categories
//first do the translations part for GUI
 
  $labels = array(
    'name' => _x( 'Devices', 'taxonomy general name' ),
    'singular_name' => _x( 'Device', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Devices' ),
    'all_items' => __( 'All Devices' ),
    'parent_item' => __( 'Parent Device' ),
    'parent_item_colon' => __( 'Parent Device:' ),
    'edit_item' => __( 'Edit Device' ), 
    'update_item' => __( 'Update Device' ),
    'add_new_item' => __( 'Add New Device' ),
    'new_item_name' => __( 'New Device Name' ),
    'menu_name' => __( 'Devices' ),
  );    
 
// Now register the taxonomy
 
  register_taxonomy('Devices',array('x-portfolio'), array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'show_admin_column' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'Device' ),
  ));
 
}

I don’t know what code you used in the place of array('post') that made it show nothing but I would guess it’s probably just portfolio. The correct slug of our Portfolio post type is x-portfolio. :wink:

Hope this helps.

And that’s why you guys rock! Thanks so much!!

You’re always welcome!

Cheers.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.