Skip to content

Instantly share code, notes, and snippets.

@vanaf1979
Last active April 15, 2024 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vanaf1979/eb3d50ff36ce05152e0eba3e688acf63 to your computer and use it in GitHub Desktop.
Save vanaf1979/eb3d50ff36ce05152e0eba3e688acf63 to your computer and use it in GitHub Desktop.
Add content to the WordPress viewpost post overview/list column
<?php
/**
* add_view_post_overview_column_content.
*
* Add content to the viewpost post overview/list column.
*
* @see https://since1979.dev/___/
* @uses get_permalink() https://developer.wordpress.org/reference/functions/get_permalink/
* @uses get_the_ID() https://developer.wordpress.org/reference/functions/get_the_id/
*/
function add_view_post_overview_column_content($column)
{
if ($column !== 'viewpost') {
return;
}
echo '<a href="' . get_permalink(get_the_ID()) . '" target="_blank">View post</a>';
}
/**
* Hook: manage_posts_custom_column.
*
* @uses add_action() https://developer.wordpress.org/reference/functions/add_action/
* @uses manage_posts_custom_column https://developer.wordpress.org/reference/hooks/manage_posts_custom_column/
*/
add_action('manage_posts_custom_column', 'add_view_post_overview_column_content');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment