Backend: creating custom column for posts only
-
I’m creating custom column in my admin with:
add_filter('manage_posts_columns', 'my_columns'); function my_columns($columns) { $columns['hello'] = 'Hello'; return $columns; } /* show the custom colums */ add_action('manage_posts_custom_column', 'show_columns'); function show_columns($name) { global $post; switch ($name) { case 'hello': echo 'Hi!'; break; } }
Well this works fine! But i just want a custom column for the post overview, and with the method above it also shows at all my custom post types!
You can remove the columns at your custom post types with:
add_filter('manage_edit-custompt_columns', 'remove_post_columns'); function remove_post_columns($defaults) { unset($defaults['hello']); return $defaults; }
But i think that’s not a good way to do it. I just want to set custom columns for posts only and not all custom post types.
Any way to do this right?
Thanks!
- The topic ‘Backend: creating custom column for posts only’ is closed to new replies.