Last active
April 15, 2024 10:21
-
-
Save vanaf1979/eb3d50ff36ce05152e0eba3e688acf63 to your computer and use it in GitHub Desktop.
Add content to the WordPress viewpost post overview/list column
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_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