Skip to content

Instantly share code, notes, and snippets.

@dcangulo
Created April 4, 2018 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcangulo/4362016585df0e2554ce47e1a98791f6 to your computer and use it in GitHub Desktop.
Save dcangulo/4362016585df0e2554ce47e1a98791f6 to your computer and use it in GitHub Desktop.
A simple WordPress plugin that shows the last modified date of a post. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: Custom Column Plugin Example
Plugin URI: https://www.davidangulo.xyz/portfolio/
Description: Add a custom column on WordPress posts.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
License: GPL2
*/
add_filter("manage_posts_columns","column_head");
function column_head($columns) {
$columns["custom_column"] = "Last Modified Date";
return $columns;
}
add_action("manage_posts_custom_column","column_content",10,2);
function column_content($column_name,$post_ID) {
if ($column_name == "custom_column") {
echo "Last Modified<br><abbr title=".get_the_modified_time("Y/m/d").get_the_modified_time("h:i:s a").">".get_the_modified_time("Y/m/d")."</abbr>";
}
}
//Visit the tutorial for more information
//https://www.davidangulo.xyz/website-development/how-to-add-custom-column-in-wordpress-post/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment