jjgrainger / PostTypes

Simple WordPress custom post types.
https://posttypes.jjgrainger.co.uk/
MIT License
373 stars 47 forks source link

add id column to post category taxonomy #48

Closed mmjaeger closed 4 years ago

mmjaeger commented 5 years ago

Hello How could I add an ID column to the posts -> categories edit screen?

mmjaeger commented 5 years ago

got it to work like - hope that's the right way to do it `$cats = new Taxonomy( 'category' ); $cats->posttype( 'post' );

$cats->columns()->add( array(
    'pid' => __( 'ID' ),
) );

$cats->columns()->populate( 'pid', function ( $content, $column, $term_id ) {
    echo $term_id;
} );

$cats->columns()->order( array(
    'pid' => 1
) );

$cats->register();  // register category for posttype 'gear'`
mmjaeger commented 5 years ago

what's not working though is adding a column to the post_type "attachment" like this:`

$atts = new PostType( 'attachment' );
$atts->columns()->add( array(
    'pid'   => __( 'ID' ),
) );

$atts->columns()->populate( 'pid', function ( $column, $post_id ) {
    echo $post_id;
} );

$atts->columns()->order( array(
    'pid' => 1
) );

$atts->register();`

am I missing something??

jjgrainger commented 5 years ago

@mmjaeger The attachment post type has a slightly different actions and filters to other post types.

This has been raised in another issue (#5) and will be looking into a fix.

jjgrainger commented 4 years ago

Closing this issue out in favour of #5