1

I add my custom taxonomy column with this code:

function manage_my_category_columns($columns)
    {
     if ( !isset($_GET['taxonomy']) || $_GET['taxonomy'] != 'products' )
     return $columns;
     $columns['image_column'] = 'Image';
     return $columns;
}
add_filter('manage_edit-products_columns','manage_my_category_columns');

function manage_category_custom_fields($deprecated,$column_name,$term_id){
     if ($column_name == 'image_column') {
       $t_id = $term_id;
       $cat_meta = get_option( "products_$t_id");
       echo "<img src='".$cat_meta['img']."' style='height:50px;width:50px;'/>";

     }
    }
add_action('manage_products_custom_column','manage_category_custom_fields',10,3);

When I add new category, custom column not shown immediately after create: enter image description here

After page refresh the custom column will be shown: enter image description here

Is there any way to show custom column with default columns immediately after create new category?

2

What is happening is that:

  • the page /wp-admin/edit-tags.php uses $_GET['taxonomy']

  • and /wp-admin/admin-ajax.php, fired when we create a new term, uses $_POST['taxonomy']

To solve it, use $_REQUEST in manage_my_category_columns().
It will cover both GET and POST:

if ( !isset( $_REQUEST['taxonomy']) || $_REQUEST['taxonomy'] != 'products' )

Related Q&A:
WP List Table custom quick edit box - post meta data missing and columns change on submit

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.