I’m trying to find out whether there’s a way to move custom post field columns that have been added to a custom post type admin listing in “Edit Post Type,” relative not to each other but to the standard admin columns (“Title,” “Date,” “Author,” &c.).
To move admin columns ordinarily, one uses a “manage_posts” filter something like this:
function myfunc_reorder_columns( $columns ) {
$new_columns = array();
foreach( $columns as $key => $value ) {
if ( $key == 'date' )
$new_columns['author'] = 'Author'; // Move author column before date column
$new_columns[$key] = $value;
}
return $new_columns;
}
add_filter( 'manage_mycustomposttype_posts_columns', 'myfunc_reorder_columns' );
If instead of one of the standard columns I use the name of a Types custom field that I’ve added to the admin columns, this filter doesn’t do anything. Evidently the added custom field columns aren’t the same kind of thing, in the admin page view, as the standard columns.
Is there a way to move added custom field columns relative to standard admin columns?
I'm not sure whether it is possible, but I would suggest first that you add your callback to the filter with a higher priority so that it runs after other callbacks (in case Types uses the same filter to insert its fields as columns), e.g. 100 or higher.
Also, bear in mind that Types custom fields have a prefix of wpcf-, so a custom field with a slug of due-date actually has a post meta key of wpcf-due-date, and that is likely what would be required here.
I’d thought of the need to add the wpcf- prefix, but hadn’t considered firing order. Including a prioritization value did it. Thank you!
I’ll just note that for what I needed, which entails moving several columns, I didn’t get the result I needed with a single function. Some recommendations to be found in Stack Exchange and discussion elsewhere suggest that multiple columns should be moveable using a single function, but what worked for me looks like this: