Code Snippets
These code snippets can be placed in your theme's functions.php
file.
Update the modified date after using inline edit for custom fields
By default, the Post Modified date will not be updated when you use inline edit for custom field related columns. This is because of the default behavior of WordPress that does not update a post when using the update_post_meta
. In Admin Columns we chose to leave this as it, but with the following snippet, you can update the post to update the post modified date.
Remove columns based on role
By adding this piece of code to your theme’s functions.php you will be able to remove any columns based on a user role.
Learn more about how to display columns based on user or role »
Only show the inline edit icons on hover
By default, Admin Columns will display an edit icon on each column value that's been made editable. If you like to hide these icons, and only want them visible when you hover over the actual value, you can use the code snippet below.
Result
Allow another role to manage columns
By default, only administrators are allowed to manage columns. By adding this piece of code to your theme’s functions.php you will be able to allow users with another role to manage columns. In this example, we are adding the manage_admin_columns
capability to the editor
role.
Hooks: Action and Filters
Admin Columns has many WordPress PHP hooks that allow you to change the default behavior and even extend it with new functionality. All filters and actions are listed here.