I know this question has likely been asked many times, but I've tried so many supposed solutions to this issue and so far nothing has seem to have worked.
I'm using the Advanced Custom Fields plugin to create a custom dropdown field called statuses
to a custom post type st_kb
. With the field created I've successfully managed to get a column shown in the admin post section of the dashboard with the field shown in it. However, I would like this to be sortable and so far I have been unable to get it working.
Here is my current code:
function add_column($cols) {
$cols['bkb_status'] = 'Status';
return $cols;
}
function add_sort_register_sortable($cols) {
$cols['bkb_status'] = 'statuses';
return $cols;
}
function my_custom_columns($column) {
global $post;
if ($column == 'bkb_status') {
if (get_field('statuses') != false) {
echo get_field('statuses');
} else {
echo 'Not set';
}
}
}
add_action("manage_st_kb_posts_custom_column", "my_custom_columns");
add_filter("manage_st_kb_posts_columns", "add_column");
add_filter("manage_st_kb_posts_sortable_columns", "add_sort_register_sortable");
This will show the column in the correct table, but there are no sort arrows available. Please can someone help point out to me what is wrong with this code, or else I may have a plugin conflict?
manage_edit-st_kb_sortable_columns
(source)