Daily Archives: 18 November 2014

Create a sortable ‘Modified Date’ sortable column for posts and pages in wordpress admin area 6

2016-07-14: Post updated to support both pages and posts without redundant/useless code

Paste the following in the functions.php file of your theme:

// Register the column for modified date
function bf_post_modified_column_register( $columns ) {
    $columns['post_modified'] = __( 'Modified Date', 'mytextdomain' );
    return $columns;
add_filter( 'manage_edit-post_columns', 'bf_post_modified_column_register' );
add_filter( 'manage_edit-page_columns', 'bf_post_modified_column_register' );

// Display the modified date column content
function bf_post_modified_column_display( $column_name, $post_id ) {
    if ( 'post_modified' != $column_name ){
    $post_modified = get_post_field('post_modified', $post_id);
    if ( !$post_modified ){
        $post_modified = '' . __( 'undefined', 'mytextdomain' ) . '';
    echo $post_modified;
add_action( 'manage_posts_custom_column', 'bf_post_modified_column_display', 10, 2 );
add_action( 'manage_pages_custom_column', 'bf_post_modified_column_display', 10, 2 );

// Register the modified date column as sortable
function bf_post_modified_column_register_sortable( $columns ) {
    $columns['post_modified'] = 'post_modified';
    return $columns;
add_filter( 'manage_edit-post_sortable_columns', 'bf_post_modified_column_register_sortable' );
add_filter( 'manage_edit-page_sortable_columns', 'bf_post_modified_column_register_sortable' );

When you refresh http://<Your Domain>/wp-admin/edit.php or http://<Your Domain>/wp-admin/edit.php?post_type=page the ‘Modified Date’ column will be visible and sortable.

Bash: How to execute from root account a script as another user

There are times that you need to execute a script as another user, usually to make sure you do not mess up the access rights of the files that will be produced after the execution of the script.

An easy way to do it is using the command su (su allows to run commands with a substitute user and group ID).

An example would be to use it as su - <USER> -c "<COMMAND>
The –  <USER> will start the shell as a login shell with an environment similar to a real login.
The -c “<COMMAND>” will pass the command after -c to the newly created shell, you should wrap it in quotes if you want to pass parameters to your command.