Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add a column to the WordPress posts overview/list.
<?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
You can’t perform that action at this time.