Custom taxonomy column sortable by term option

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':
                $content = 'Yes';
                $content = 'No';
    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() )

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

    if( 'logo' == $orderby ) {

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

Leave a Reply

Your email address will not be published. Required fields are marked *