Last active
June 28, 2020 16:38
-
-
Save vanaf1979/e6bdc9cb0ee2defec51a8c2911fca046 to your computer and use it in GitHub Desktop.
Add a column to the WordPress posts overview/list.
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_view_post_overview_column. | |
* | |
* Add a column to the posts overview/list. | |
* | |
* @see https://since1979.dev/___/ | |
* @uses __() https://developer.wordpress.org/reference/functions/__/ | |
*/ | |
function add_view_post_overview_column($columns) | |
{ | |
$cols = array(); | |
foreach ($columns as $col_name => $col_data) { | |
$cols[$col_name] = $col_data; | |
if ($col_name === 'title') { | |
$cols['viewpost'] = __('View post', 'namespace'); | |
} | |
} | |
return $cols; | |
} | |
/** | |
* Hook: manage_posts_columns. | |
* | |
* @uses add_action() https://developer.wordpress.org/reference/functions/add_action/ | |
* @uses manage_posts_columns https://developer.wordpress.org/reference/hooks/manage_posts_columns/ | |
*/ | |
add_filter('manage_posts_columns', 'add_view_post_overview_column', 20); | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment