WordPress.org

Ready to get started?Download WordPress

Forums

Custom Taxonomies Issue in WP 3.1 (2 posts)

  1. Ryan
    Member
    Posted 3 years ago #

    Well, this has got a little more interesting...if I register a post type as follows 3.1 does not show the custom taxonomies...BUT if I just change the name of the registered custom post type it works. Some names seem to work and others fail completely. This seems like a bug unless the name of a custom post type is severely limited by a list that I don't know...If anyone has any ideas I would love to hear.

    I have created a new blank theme (just style.css, index.php and functions.php) to test the custom taxonomy...

    THIS ONE DOES NOT WORK...

    <?php
    //*******************************************
    //  Create Post Type
    //*******************************************
    add_action( 'init', 'create_eTicket_post_type' );
    function create_eTicket_post_type()
    {
    	$labels = array(
    		'name' => _x('eTickets', 'post type general name'),
    		'singular_name' => _x('eTicket', 'post type singular name'),
    		'add_new' => _x('Add New', 'eTicket'),
    		'add_new_item' => __("Add New eTicket"),
    		'edit_item' => __("Edit eTicket"),
    		'new_item' => __("New eTicket"),
    		'view_item' => __("View eTickets"),
    		'search_items' => __("Search eTickets"),
    		'not_found' =>  __('No eTickets found'),
    		'not_found_in_trash' => __('No eTickets found in Trash'),
    		'parent_item_colon' => ''
    	);
    	$args = array(
    		'labels' => $labels,
    		'public' => true,
    		'publicly_queryable' => true,
    		'show_ui' => true,
    		'query_var' => true,
    		'rewrite' => true,
    		'capability_type' => 'post',
    		'hierarchical' => false,
    		'menu_position' => 5,
    		'taxonomies' => array('department', 'milestone', 'status', 'priority', 'assigned'),
    		'supports' => array('author', 'title', 'editor', 'comments', 'revisions')
    	);
    	register_post_type('eTickets', $args);
    	unset($args, $labels);
    }
    
    //*******************************************
    //  Create Milestone Taxonomy
    //*******************************************
    add_action( 'init', 'milestone_init' );
    function milestone_init() {
    	$labels = array(
    		'name' => _x('Milestones', 'taxonomy general name'),
    		'singular_name' => _x('Milestones', 'taxonomy singular name'),
    		'search_items' => __('Search Milestones'),
    		'popular_items' => __('Popular Milestones'),
    		'all_items' => __('All Milestones'),
    		'parent_item' => __('Parent Milestone'),
    		'parent_item_colon' => __('Parent Milestone:'),
    		'edit_item' => __('Edit Milestone'),
    		'update_item' => __('Update Milestone'),
    		'add_new_item' => __('Add New Milestone'),
    		'new_item_name' => __('New Milestone Name')
    	);
    
    	$args = array(
    		'labels' => $labels,
    		'public' => true,
    		'hierarchical' => true
    	);
    
    	// create a new taxonomy
    	register_taxonomy( 'milestone', 'eTickets', $args );
    	unset($args, $labels);
    }
    
    ?>

    THIS ONE DOES WORK!!

    <?php
    //*******************************************
    //  Create Post Type
    //*******************************************
    add_action( 'init', 'create_eTicket_post_type' );
    function create_eTicket_post_type()
    {
    	$labels = array(
    		'name' => _x('eTickets', 'post type general name'),
    		'singular_name' => _x('eTicket', 'post type singular name'),
    		'add_new' => _x('Add New', 'eTicket'),
    		'add_new_item' => __("Add New eTicket"),
    		'edit_item' => __("Edit eTicket"),
    		'new_item' => __("New eTicket"),
    		'view_item' => __("View eTickets"),
    		'search_items' => __("Search eTickets"),
    		'not_found' =>  __('No eTickets found'),
    		'not_found_in_trash' => __('No eTickets found in Trash'),
    		'parent_item_colon' => ''
    	);
    	$args = array(
    		'labels' => $labels,
    		'public' => true,
    		'publicly_queryable' => true,
    		'show_ui' => true,
    		'query_var' => true,
    		'rewrite' => true,
    		'capability_type' => 'post',
    		'hierarchical' => false,
    		'menu_position' => 5,
    		'taxonomies' => array('department', 'milestone', 'status', 'priority', 'assigned'),
    		'supports' => array('author', 'title', 'editor', 'comments', 'revisions')
    	);
    	register_post_type('e', $args);
    	unset($args, $labels);
    }
    
    //*******************************************
    //  Create Milestone Taxonomy
    //*******************************************
    add_action( 'init', 'milestone_init' );
    function milestone_init() {
    	$labels = array(
    		'name' => _x('Milestones', 'taxonomy general name'),
    		'singular_name' => _x('Milestones', 'taxonomy singular name'),
    		'search_items' => __('Search Milestones'),
    		'popular_items' => __('Popular Milestones'),
    		'all_items' => __('All Milestones'),
    		'parent_item' => __('Parent Milestone'),
    		'parent_item_colon' => __('Parent Milestone:'),
    		'edit_item' => __('Edit Milestone'),
    		'update_item' => __('Update Milestone'),
    		'add_new_item' => __('Add New Milestone'),
    		'new_item_name' => __('New Milestone Name')
    	);
    
    	$args = array(
    		'labels' => $labels,
    		'public' => true,
    		'hierarchical' => true
    	);
    
    	// create a new taxonomy
    	register_taxonomy( 'milestone', 'e', $args );
    	unset($args, $labels);
    }
    
    ?>

    The only lines that were changed were the two lines that included...
    register_taxonomy( 'milestone', 'e', $args );

    Anyone else running into issues or have any ideas?

  2. Ryan
    Member
    Posted 3 years ago #

    UPDATE: It seems you can't use any capital letters in a custom taxonomy name...just be aware...

Topic Closed

This topic has been closed to new replies.

About this Topic