Créer un autre exemple du Tags en WordPress

Créer un autre exemple du Tags en WordPress

add_action( 'init', 'create_tagPrimary_taxonomies', 0 );

//create two taxonomies, genres and tags for the post type "tag"
function create_tagPrimary_taxonomies() 
{
  // Add new taxonomy, NOT hierarchical (like tags)
  $labels = array(
    'name' => _x( 'Primary Tags', 'taxonomy general name' ),
    'singular_name' => _x( 'Primary Tag', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Primary Tags' ),
    'popular_items' => __( 'Popular Primary Tags' ),
    'all_items' => __( 'All Primary Tags' ),
    'parent_item' => null,
    'parent_item_colon' => null,
    'edit_item' => __( 'Edit Primary Tag' ), 
    'update_item' => __( 'Update Primary Tag' ),
    'add_new_item' => __( 'Add New Primary Tag' ),
    'new_item_name' => __( 'New Primary Tag Name' ),
    'separate_items_with_commas' => __( 'Separate Primary tags with commas' ),
    'add_or_remove_items' => __( 'Add or remove Primary tags' ),
    'choose_from_most_used' => __( 'Choose from the most used Primary tags' ),
    'menu_name' => __( 'Primary Tags' ),
  ); 

  register_taxonomy('primary-tag','post',array(
    'hierarchical' => false,
    'labels' => $labels,
    'show_ui' => true,
    'update_count_callback' => '_update_post_term_count',
    'query_var' => true,
    'rewrite' => array( 'slug' => 'primary-tag' ),
  ));
}

 

Affichage

$termss = wp_get_post_terms(get_the_ID(), 'primary-tag', '');
	$locationss = array();
	if ( count($termss) > 0 ){
		echo '<ul class="tags-list">';
		foreach ( $termss as $termsss ){
			echo '<li><a>'.$termsss->name.'</a></li>';
		}
		echo '</ul>';
	}