Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
$5
Show custom post column in admin first not last
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.
This question has been answered.
Joe Calithia | 10/01/10 at 11:22am
Edit
(7) Possible Answers Submitted...
See a chronological view of answers?
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
-

Last edited:
10/01/10
11:37amPippin Williamson says:It depends on how you've set up your custom column.
Here's an example I've used recently:
function announcement_edit_columns($announcement_columns){
$announcement_columns = array(
"cb" => "<input type=\"checkbox\" />",
"title" => "Title",
"topics" => "Topics",
"author" => "Author",
"date" => "Date",
"thumbnail" => "Thumbnail",
);
return $announcement_columns;
}
function announcement_columns_display($announcement_columns){
. . . . code for custom column display
}
add_filter("manage_edit-wp_announcements_columns", "announcement_edit_columns");
add_action("manage_posts_custom_column", "announcement_columns_display");
By simply changing the order of the items in $announcement_columns = array, you can change the order the columns are displayed.- 10/01/10 2:16pm
Pippin Williamson says:You need to include the other, default columns as well before you do
return $columns;
So your function should be:
function dt_add_post_columns($columns){
$columns['cb'] = '<input type="checkbox" />';
$columns['dt-post-thumbnail'] = __("Thumbnail");
$columns['title'] = __('Title');
$columns['author'] = __('Author');
$columns['categories'] = __('Category');
$columns['tags'] = __('Tags');
$columns['comments'] = __('Comments');
$columns['date'] = _x('Date', 'column name');
return $columns;
}
- 10/01/10 2:16pm
-

Last edited:
10/01/10
11:38amUtkarsh Kukreti says:Please post the current code that you are using (for the filter).
- 10/01/10 2:14pm
Utkarsh Kukreti says:Try
function dt_add_post_columns($columns){
$columns = array_merge( array( 'dt-post-thumbnail' => __("Thumbnail") ), $columns );
return $columns;
}
- 10/01/10 2:14pm
-

Last edited:
10/01/10
11:44amCosmin Popovici says:Damn, Pippin was fast :)
He's right, just place the "thumbnail" => "Thumbnail" before the "title" one and it'll work ;)
So here's the final code I'd use:
<?php
// Add custom columns to manage posts page
// Add to admin_init function
add_filter('manage_posts_columns', 'add_new_my_columns');
function add_new_my_columns($my_columns) {
$new_my_columns['cb'] = '<input type="checkbox" />';
$new_my_columns['thumbnail'] = __('Post Thumbnail');
$new_my_columns['title'] = __('Title');
$new_my_columns['author'] = __('Author');
$new_my_columns['categories'] = __('Category');
$new_my_columns['tags'] = __('Tags');
$new_my_columns['comments'] = __('Comments');
$new_my_columns['date'] = _x('Date', 'column name');
return $new_my_columns;
}
// Add to admin_init function
add_action('manage_posts_custom_column', 'manage_my_columns', 10, 2);
?>Previous versions of this answer: 10/01/10 at 11:44am
- 10/01/10 2:09pm
Joe Calithia says:This doesn't seem to be working for me. Here is my code...
<?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){
$columns['my-post-thumbnail'] = __("Thumbnail");
return $columns;
}
function dt_display_post_columns($column){
global $post;
switch($column):
case 'my-post-thumbnail':
my_image(false, 48, 48, 'my-admin-thumb');
break;
endswitch;
} - 10/01/10 2:11pm
Joe Calithia says:Sorry.. that code was messed up. Here is my working code.
<?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){
$columns['dt-post-thumbnail'] = __("Thumbnail");
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;
}
- 10/01/10 3:48pm
Cosmin Popovici says:$columns['dt-post-thumbnail'] = __("Thumbnail");
That won't work, because WordPress doesn't know of dt-post-thumbnail.
Use just this:$columns['thumbnail'] = __("Thumbnail"); - 10/01/10 5:23pm
Joe Calithia says:Well this code...
<?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){
$columns['dt-post-thumbnail'] = __("Thumbnail");
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;
}
...is working. See the original attached image. It sends it to the last column. How can I change it so that it shows up as the first column?
- 10/01/10 2:09pm
-
Last edited:
10/01/10
11:50am -

Last edited:
10/01/10
11:57amNavjot Singh says:Try this:
add_filter("manage_posts_columns", "my_column",10,2);
add_action("manage_posts_custom_column", "my_column",10,2);
Where you can change the value of 2 to adjust the position of column. Not tested though. -

Last edited:
10/01/10
2:46pmStephanie Leary says:This should do it.
<?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){
$newcolumn['dt-post-thumbnail'] = __("Thumbnail");
return $columns + $newcolumn;
}
function dt_display_post_columns($column){
global $post;
switch($column):
case 'dt-post-thumbnail':
dt_image(false, 48, 48, 'dt-admin-thumb');
break;
endswitch;
}
-

Last edited:
10/01/10
9:03pmDenzel Chia says: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;
}
- 10/01/10 6:55pm
Denzel Chia says:Added the attachment screen shot as proof.
Notice the position of the thumbnail column, is second to check boxes.
"There are no images" in my example because I do not know what dt_image() function is.
Butthis code will definitely work for you!
Thanks for the learning opportunity!
- 10/01/10 6:55pm
This question has expired.
Current status of this question: Completed
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
