Right now I use the following code to create a custom post type and assign a taxonomy to it:

// === CUSTOM TAXONOMIES === //
add_action('init', 'my_custom_taxonomies', 0);

function my_custom_taxonomies() {
 register_taxonomy(
  'section',  // internal name = machine-readable taxonomy name
  'static_content',  // object type = post, page, link, or custom post-type
  array(
   'hierarchical' => true,
   'labels' => array(
    'name' => __( 'Section' ),
    'singular_name' => __( 'Section' ),
    'add_new_item' => 'Add New Section',
    'edit_item' => 'Edit Section',
    'new_item' => 'New Section',
    'search_items' => 'Search Section',
    'not_found' => 'No Sections found',
    'not_found_in_trash' => 'No Sections found in trash',
    'all_items' => __( 'All Sections' ),
   ),
   'query_var' => true, // enable taxonomy-specific querying
   'rewrite' => array( 'slug' => 'section' ), // pretty permalinks for your taxonomy?
  )
 );
 wp_insert_term('Footer', 'section');
 wp_insert_term('Header', 'section');
 wp_insert_term('Front Page Intro', 'section');
 wp_insert_term('Front Page Content', 'section');
}

// === CUSTOM POST TYPES === //
add_action( 'init', 'create_my_post_types' );

function create_my_post_types() {
 register_post_type( 'static_content',
  array(
   'labels' => array(
    'name' => __( 'Static Content' ),
    'singular_name' => __( 'Static Content' ),
    'add_new_item' => 'Add New Static Content',
    'edit_item' => 'Edit Static Content',
    'new_item' => 'New Static Content',
    'search_items' => 'Search Static Content',
    'not_found' => 'No Static Content found',
    'not_found_in_trash' => 'No Static Content found in trash',
   ),
   '_builtin' => false,
   'public' => true,
   'hierarchical' => false,
   'taxonomies' => array( 'section'),
   'supports' => array(
    'title',
    'editor',
    'excerpt'
   ),
   'rewrite' => array( 'slug' => 'static_content', 'with_front' => false )
  )
 );
}

When I click the menu of the custom post type (in this case “Static Content”), I see in the table/column (where all the posts are displayed) the following information: Title, Author and Date. I would like to show the taxonomy assigned to that post (in this case the “Section”.)

How do I do that?

Leave a Reply

Your email address will not be published.