Link to home
Start Free TrialLog in
Avatar of AccurateDesign
AccurateDesign

asked on

Wordpress Custom Post Type and Custom Taxonomy Invalid

I have a custom post type called EWD Item (ewd-item slug). Tied to this custom post type, is a custom taxonomy called EWD Sector (ewdsector slug). I have a development server and live server which are both identical except that the live server is a WP Multi-site installation. When I run get_terms('ewdsector') on the dev site, it returns all the terms but when I run it on the live site, it gives me an "Invalid Taxonomy" error.

Here's the custom post type registration code:
function register_ewd_item_posttype() {
		$labels = array(
			'name' 				=> _x( 'EWD Items', 'post type general name' ),
			'singular_name'		=> _x( 'EWD Item', 'post type singular name' ),
			'add_new' 			=> __( 'Add New' ),
			'add_new_item' 		=> __( 'EWD Item' ),
			'edit_item' 		=> __( 'EWD Item' ),
			'new_item' 			=> __( 'EWD Item' ),
			'view_item' 		=> __( 'EWD Item' ),
			'search_items' 		=> __( 'EWD Item' ),
			'not_found' 		=> __( 'EWD Item' ),
			'not_found_in_trash'=> __( 'EWD Item' ),
			'parent_item_colon' => __( 'EWD Item' ),
			'menu_name'			=> __( 'EWD Items' )
		);
		
		$taxonomies = array();

		$supports = array('title','editor','author','thumbnail','revisions');
		
		$post_type_args = array(
			'labels' 			=> $labels,
			'singular_label' 	=> __('EWD Item'),
			'public' 			=> true,
			'show_ui' 			=> true,
			'publicly_queryable'=> true,
			'query_var'			=> true,
			'exclude_from_search'=> true,
			'show_in_nav_menus'	=> false,
			'capability_type' 	=> 'post',
			'has_archive' 		=> true,
			'hierarchical' 		=> false,
			'rewrite' 			=> array('slug' => 'ewd-item', 'with_front' => false ),
			'supports' 			=> $supports,
			'menu_position' 	=> 5,
			'taxonomies'		=> $taxonomies
		 );
		 register_post_type('ewd-item',$post_type_args);
	}
	add_action('init', 'register_ewd_item_posttype');

Open in new window


Here's the custom taxonomy registration code:
function register_ewdsector_tax() {
			$labels = array(
				'name' 					=> _x( 'EWD Sectors', 'taxonomy general name' ),
				'singular_name' 		=> _x( 'EWD Sector', 'taxonomy singular name' ),
				'add_new' 				=> _x( 'Add New EWD Sector', 'EWD Sector'),
				'add_new_item' 			=> __( 'Add New EWD Sector' ),
				'edit_item' 			=> __( 'Edit EWD Sector' ),
				'new_item' 				=> __( 'New EWD Sector' ),
				'view_item' 			=> __( 'View EWD Sector' ),
				'search_items' 			=> __( 'Search EWD Sectors' ),
				'not_found' 			=> __( 'No EWD Sector found' ),
				'not_found_in_trash' 	=> __( 'No EWD Sector found in Trash' ),
			);
			
			$pages = array('ewd-item');
			$args = array(
				'labels' 			=> $labels,
				'singular_label' 	=> __('EWD Sector'),
				'public' 			=> true,
				'show_ui' 			=> true,
				'hierarchical' 		=> false,
				'show_tagcloud' 	=> false,
				'show_in_nav_menus' => false,
				'rewrite' 			=> array('slug' => 'ewdsector', 'with_front' => false ),
			 );
			register_taxonomy('ewdsector', $pages, $args);
		}
		add_action('init', 'register_ewdsector_tax');

Open in new window


When I do
$terms = get_terms('ewdsector');
			print_r($terms);

Open in new window


It returns WP_Error Object Invalid Taxonomy.

Also, there's something a bit odd going on in the database.

On my dev server, the "term_taxonomy_id" and "term_id" are always different values while on the live server, they're all equal.

I'm doing all I can to replicate "Invalid Taxonomy" error on my dev site but can't seem to figure out the issue.

How can I get the custom taxonomy working on the live site?

Thanks in advance!
ASKER CERTIFIED SOLUTION
Avatar of eemit
eemit
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial