Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Show custom post column in admin first not last WordPress

  • SOLVED

I'm using this...

add_filter("manage_posts_columns", "my_column");
add_action("manage_posts_custom_column", "my_column");


I have it working but I'd like my new column to be first not last.

See attached image.

Answers (7)

2010-10-01

Denzel Chia answers:

Hi Joe,

Based on your working codes, simply unset $column and reconstruct the array before returning.

Use the following codes, I had tested in my localhost.


<?php
add_filter("manage_posts_columns", "dt_add_post_columns");
add_action("manage_posts_custom_column", "dt_display_post_columns");

function dt_add_post_columns($columns){

unset($columns);

$columns = array(

'cb' => '<input type="checkbox"/>',

'dt-post-thumbnail' => __("Thumbnail"),

'title' => __('Title'),

'author' => __('Author'),

'categories' => __('Category'),

'tags' => __('Tags'),

'comments' => '<img src="images/comment-grey-bubble.png" alt="Comments">',

'date' => _x('Date', 'column name'),

);

return $columns;

}



function dt_display_post_columns($column){

global $post;

switch($column):

case 'dt-post-thumbnail':

dt_image(false, 48, 48, 'dt-admin-thumb');

break;

endswitch;
}



Denzel Chia comments:

Added the attachment screen shot as proof.

<strong>Notice the position of the thumbnail column, is second to check boxes.</strong>

"There are no images" in my example because I do not know what dt_image() function is.

But <blockquote>this code will definitely work for you!</blockquote>

Thanks for the learning opportunity!