Ready to get started?Download WordPress


[resolved] Custom Taxonomies Filter in manage posts (7 posts)

  1. prfbst
    Posted 3 years ago #

    I created a custom post page a taxonomy. But is there a way to show a filter box on the manage post page overview (Like Category Filter under Posts)? thanks

  2. prfbst
    Posted 3 years ago #

    I see that you can do it by hand:

    book being the new post type and 3 the id of the custom taxonomy

    I presume you have to add the box manually? Any support link on this? thanks

  3. prfbst
    Posted 3 years ago #

    For anyone who is interested:

    register_post_type( 'book', array(
    	'labels' => array(
    		'name' => 'Books',
    		'singular_name' => 'Book',
    		'add_new' => 'Add New',
    		'add_new_item' => 'Add New Book',
    		'edit_item' => 'Edit book',
    		'edit' => 'Edit',
    		'new_item' => 'New Book',
    		'view_item' => 'View Book',
    		'search_items' => 'Search Books',
    		'not_found' => 'No books found',
    		'not_found_in_trash' => 'No books found in Trash',
    		'view' => 'View Book'
    	'public' => true,
    	'capability_type' => 'post',
    	'hierarchical' => false,
    	'rewrite' => true,
    	'query_var' => true,
    	'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'custom-fields', 'comments' ),
    	'taxonomies' => array('category','post_tag')
    		'hierarchical' => true,
    		'label' => 'Categoriën',
    		'public' => true,
    		'query_var' => true,
    		'show_tagcloud' => true,
    		'rewrite' => Array(
    			'slug' => 'book_category')
    function add_new_columns($defaults) {
        $defaults['book_cats'] = __('Categoriën');
        return $defaults;
    function add_column_data( $column_name, $post_id ) {
    	if( $column_name == 'book_cats' ) {
    		$_posttype 	= 'book';
    		$_taxonomy 	= 'book_category';
    		$terms 		= get_the_terms( $post_id, $_taxonomy );
    		if ( !empty( $terms ) ) {
    			$out = array();
    			foreach ( $terms as $c )
    				$_taxonomy_title = esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display'));
    				$out[] = "<a href='edit.php?book_category=$_taxonomy_title&post_type=$_posttype'>$_taxonomy_title</a>";
    			echo join( ', ', $out );
    		else {
    add_filter( 'manage_book_posts_columns', 'add_new_columns' );
    add_action( 'manage_posts_custom_column', 'add_column_data', 10, 2 );
  4. sebmeric
    Posted 3 years ago #

    Maybe you'll find the answer to this question in this thread :


    Hope this will help.

  5. prfbst
    Posted 3 years ago #

    Thanks i did find an anwser there a while ago:)

  6. maorb
    Posted 3 years ago #

    I tried your code and I see it adds the column at the end as the last column. How can the order of the columns be changed?


  7. hafman
    Posted 3 years ago #

    This one actually works and it isn't pages long! However, if i modify the variables only slightly it doesn't work, changing "book_cats" specifically stops any categories appearing in the list. So:

    1. Is this compatible with WP 3.0.5?
    2. How can i alter this to suit my own custom post/taxonomy type?
    3. What does "book_cats" relate to?

    Thanks (if you reply that is...)

Topic Closed

This topic has been closed to new replies.

About this Topic