• Resolved prfbst

    (@prfbst)


    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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter prfbst

    (@prfbst)

    I see that you can do it by hand:
    edit.php?s&post_status=all&post_type=book&mode=list&action=-1&m=0&cat=3&action2=-1

    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

    Thread Starter prfbst

    (@prfbst)

    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')
    	)
    );
    register_taxonomy(
    	'book_category',
    	'book',
    	array(
    		'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 {
    			_e('Uncategorized');
    		}
    	}
    }
    add_filter( 'manage_book_posts_columns', 'add_new_columns' );
    add_action( 'manage_posts_custom_column', 'add_column_data', 10, 2 );

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

    http://wordpress.org/support/topic/show-categories-filter-on-custom-post-type-list

    Hope this will help.

    Thread Starter prfbst

    (@prfbst)

    Thanks i did find an anwser there a while 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?

    thanks

    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…)

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Custom Taxonomies Filter in manage posts’ is closed to new replies.