Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codehooligans/4f3d5b44f3b662b1f48c to your computer and use it in GitHub Desktop.
Save codehooligans/4f3d5b44f3b662b1f48c to your computer and use it in GitHub Desktop.
Codehooligans.com: Adding Custom Columns to WordPress Post listing
<?php
add_filter( 'manage_edit-post_columns', 'admin_post_header_columns', 10, 1);
add_action( 'manage_posts_custom_column', 'admin_post_data_row', 10, 2);
function admin_post_header_columns($columns)
{
if (!isset($columns['note']))
$columns['note'] = "Notes";
return $columns;
}
function admin_post_data_row($column_name, $post_id)
{
switch($column_name)
{
case 'note':
// Logic to display post 'Note' field information here.
// $post_note = get_post_meta($post_id, 'note', true);
//if ($post_note) echo $post_note;
break;
default:
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment