• hello folks,

    I registered a custom post type with two related custom taxonomies BUT in the Admin UI it only shows the Title, Author, Comments and Date columns. It’s quite limited.

    There is a way to show up my custom taxonomies as columns and take advantage of the filter functions as the built-in Post panel do with categories and tags?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Well, maybe you can use this to get started….. I use this for my custom post type (ve_products) and to display my custom taxonomy (product_category)

    // ADDS EXTRA INFO TO ADMIN MENU FOR PRODUCT POST TYPE
    add_filter("manage_edit-ve_products_columns", "voodoo_prod_edit_columns");
    add_action("manage_posts_custom_column", "voodoo_prod_custom_columns");
    
    function voodoo_prod_edit_columns( $columns ) {
    
    	// Add the extra column for product categories instead of rebuilding the whole array
    	$columns['prod_cat'] = "Product Category";
    
    	return $columns;
    }
    
    function voodoo_prod_custom_columns( $column ) {
    	global $post;
    	switch( $column ) {
    		case "description":
    			the_excerpt();
    		break;
    		case "prod_cat":
    			echo get_the_term_list( $post->ID, 'product_category', '', ', ', '' );
    		break;
    	}
    }
    Thread Starter dskbrk

    (@dskbrk)

    hey Rev. Voodoo,

    this is a great start! your snippet works very well.

    Now I’m going to look if there are also any hooks for the filter funcionalities (ex: show only posts with that term…).

    Thank you so much.

    Glad I could at least get you started!!

    Thread Starter dskbrk

    (@dskbrk)

    well, I found that adding the custom taxonomy in the edit panel url (&customtax=term) WordPress actually filter the results, so for adding filter functionalities, in the snippet above for example, is as simple as that:

    function voodoo_prod_custom_columns( $column ) {
    	global $post;
    	switch( $column ) {
    		case "customtaxonomy":
    			$terms = get_the_terms( $post->ID, 'customtaxonomy');
    			if ($terms) {
    				foreach ($terms as $term => $myterm) {
    					echo '<a href="'.get_bloginfo('url').'/wp-admin/edit.php?post_type=customtype&customtaxonomy='.$myterm->slug.'">'.$myterm->slug.'</a>';
    				}
    			}
    		break;
                    //etc...
    	}
    }

    now links filter posts by the custom taxonomy term 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom Post type admin UI with custom taxonomies’ is closed to new replies.