Taxonomies

Categories custom fields – list/add/edit:
De Redactie
Energie Nederland
More than TV

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

register_taxonomy('portfolio_categories',array('portfolio'), array(
	'hierarchical' => true,
	'labels' => $labels,
	'query_var' => true,
	'show_ui' => true
));

add_filter('manage_edit-portfolio_categories_columns', 'add_portfolio_categories_column' );

‘hierarchical’ => true -> makes a difference between checkboxes and autosuggest

 

Pre-register of taxonomies in child theme if needed


/*Rewrite taxonomy Property Categori to add it in pages*/
function wl_modify_taxonomy() {
// get the arguments of the already-registered taxonomy
$people_category_args = get_taxonomy( 'property_category' ); // returns an object

// make changes to the args
// in this example there are three changes
// again, note that it's an object
$people_category_args->show_admin_column = true;
$people_category_args->rewrite['slug'] = 'people';
$people_category_args->rewrite['with_front'] = false;

// re-register the taxonomy
register_taxonomy( 'property_category', array( 'property_cpt', 'page'), $people_category_args );
}
// hook it up to 11 so that it overrides the original register_taxonomy function
add_action( 'init', 'wl_modify_taxonomy', 11 );

 

Introducing Term Meta Data In WordPress And How To Use Them

Adding Custom Meta Fields to Taxonomies

Custom taxonomies extra fields