A quick snippet for registering custom admin columns for a post type in WordPress.
<?php | |
$post_type = 'my-post-type'; | |
add_filter( 'manage_' . $post_type . '_posts_columns', function ( $defaults ) { | |
$defaults['custom-one'] = 'One'; | |
$defaults['custom-two'] = 'Two'; | |
return $defaults; | |
} ); | |
add_action( 'manage_' . $post_type . '_posts_custom_column', function ( $column_name, $post_id ) { | |
if ( $column_name == 'custom-one' ) { | |
echo 'TODO'; | |
} | |
if ( $column_name == 'custom-two' ) { | |
echo 'TODO'; | |
} | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment