Support » Fixing WordPress » Custom Sortable Column on edit-tags.php in Admin

  • Resolved ruudvoost



    I’m trying to make the custom column I’ve added sortable.

    Register custom taxonomy

    function register_artists_taxonomy() {
      $labels = array(
        'name'                       => _x('Artists', 'Artists', 'text_domain'),
        'singular_name'              => _x('Artist', 'Artist', 'text_domain'),
        'menu_name'                  => __('Artists', 'text_domain'),
        'all_items'                  => __('All artists', 'text_domain'),
        'new_item_name'              => __('New artist', 'text_domain'),
        'add_new_item'               => __('Add new artist', 'text_domain'),
        'edit_item'                  => __('Edit artist', 'text_domain'),
        'update_item'                => __('Update artist', 'text_domain'),
        'view_item'                  => __('View artist', 'text_domain'),
        'separate_items_with_commas' => __('Separate artists with commas', 'text_domain'),
        'add_or_remove_items'        => __('Add or remove artists', 'text_domain'),
        'choose_from_most_used'      => __('Choose from the most featured artists', 'text_domain'),
        'popular_items'              => __('Popular artists', 'text_domain'),
        'search_items'               => __('Search artists', 'text_domain'),
        'not_found'                  => __('Artist not found', 'text_domain'),
          'labels'  => $labels,
          'rewrite' => array('slug' => 'artist')

    I have a custom field on that taxonomy, which I register as a column here:

    add_filter('manage_edit-artists_columns', 'set_artists_posts_columns');
    function set_artists_posts_columns($columns) {
      // Remove description, posts, wpseo columns
      // Add artist-website, posts columns
      $new_columns = array(
        'artist-website' => 'Website',
        'posts'          => 'Count'
      return array_merge($columns, $new_columns);

    I’ve enabled sorting on this column:

    add_filter('manage_edit-artists_sortable_columns', 'make_artist_website_column_sortable');
    function make_artist_website_column_sortable($columns) {
      $columns['artist-website'] = 'artist-website';
      return $columns;

    Now the problem is that the sorting doesn’t use the value within that artist-website column to sort the table. I’ve searched a lot and found several seemingly solutions, but they only get triggered on the posts page, but on my artists page in the admin panel.

    some use the request filter others the pre_get_posts hook, but they don’t get triggered on the edit-tags.php my artists taxonomy uses to manage them.

    I’ve found a topic with the exact same problem unanswered, but it’s over 2 years old.

    Any help is appreciated!

  • The topic ‘Custom Sortable Column on edit-tags.php in Admin’ is closed to new replies.