ben-a
10/24/2017 - 4:07 PM

Register custom taxonomies

<?php
// Register custom taxonomy

/**
 * Registers taxonomies
 *
 * @since 1.0.0
 *
 * @return void
 */
function register_articles_taxonomies() {
	register_taxonomy(
		'location',
		[ 'article', 'advertorials' ],
		array(
			'labels'        => array(
				'name'          => 'Location',
				'add_new_item'  => 'Add New Location',
				'new_item_name' => 'New Location'
			),
			'show_ui'       => true,
			'show_tagcloud' => false,
			'hierarchical'  => true
		)
	);
	register_taxonomy(
		'subject',
		[ 'article', 'advertorials' ],
		array(
			'labels'        => array(
				'name'          => 'Subject',
				'add_new_item'  => 'Add New Subject',
				'new_item_name' => 'New Subject'
			),
			'show_ui'       => true,
			'show_tagcloud' => false,
			'hierarchical'  => true
		)
	);
}

add_action( 'init', __NAMESPACE__ . '\register_articles_taxonomies', 100 );