theme development – Custom Column Still Is Not Sortable!

Question

Can you pls take a look at this demo and let me know why the $columns['topic-order'] is not still showing Sortable while I am having this code

add_filter( 'manage_topic-order_sortable_columns', 'my_sortable_hint_column' );
function my_sortable_hint_column( $columns ) {
    $columns['topic-order'] = 'Order';
    return $columns;
}

as you can see I am using this pattern "manage_{$this->screen->id}_sortable_columns" in the code but looks like not functioning

add_filter( 'manage_hint_posts_columns', 'set_custom_edit_book_columns' );
function set_custom_edit_book_columns($columns) {
    
      unset($columns['date']); 
    unset($columns['title']);  
    unset($columns['taxonomy-subjects']);  
    $columns['title'] = 'Topic';
    $columns['topic-order'] = 'Order';
    $columns['taxonomy-subjects'] = 'Subjects';
    $columns['date'] = 'Date';
    return $columns;
}

// Add the data to the custom columns for the book post type:
add_action( 'manage_hint_posts_custom_column' , 'custom_book_column', 10, 2 );
function custom_book_column( $column, $post_id ) {
    switch ( $column ) {

        case 'topic-order' :
            $order =  get_post_custom_values($key = 'topic_order');
            if ( is_string( $order[0] ) )
                echo $order[0];
            else
                echo 'Order Not Been Set';
            break;
    }
}


add_filter( 'manage_topic-order_sortable_columns', 'my_sortable_hint_column' );
function my_sortable_hint_column( $columns ) {
    $columns['topic-order'] = 'Order';
    return $columns;
}

I even tried this filter "manage_edit-post_sortable_columns" instead of "manage_topic-order_sortable_columns", again nothing is happening and column still is not sortable

0
Behseini 2 months 2021-07-22T23:54:21-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse