Last active
May 13, 2019 11:30
-
-
Save codehooligans/4f3d5b44f3b662b1f48c to your computer and use it in GitHub Desktop.
Codehooligans.com: Adding Custom Columns to WordPress Post listing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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