So I add my custom column like this:

function add_webshops_columns($columns){
    $key = "slug";
    if (array_key_exists($key, $columns)) {
        $new = array();
        foreach ($columns as $k => $value) {
            $new[$k] = $value;
            if ($k === $key) {
                $new['logo'] = 'Logo';
            }
        }
        return $new;
    }
    return $columns;
}

And I display the content like this:

function add_webshops_column_content($content,$column_name,$term_id){
    $term_meta = get_option( "taxonomy_".$term_id);

    switch ($column_name) {
        case 'logo':
            if(empty($term_meta['img'])){
                $content = 'Yes';
            }
            else{
                $content = 'No';
            }
            break;
        default:
            break;
    }
    return $content;
}

What I’m trying to do, is to make the custom column sortable.

So I started with this:

function make_webshops_columns_sortable($columns) {
    $columns['logo'] = 'Logo';
    return $columns;
}

I found out this only works for default columns, so not with meta value or taxonomy options.

Bit later I figured out I can make a column sortable by meta_value like this:

function my_slice_orderby( $query ) {
    if( ! is_admin() )
        return;

    $orderby = $query->get( 'orderby');

    if( 'logo' == $orderby ) {
        $query->set('meta_key','slices');
        $query->set('orderby','meta_value_num');
    }
}

BUT, that still isn’t what I’m trying to do. I have a custom field for my taxonomy terms and save that value in an option.

I get the custom value like this:

$term_meta = get_option( "taxonomy_".$term_id);
echo $term_meta['img'];

Read more here: Custom taxonomy column sortable by term option


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: