Last active
August 15, 2024 23:24
-
-
Save woraperth/fce00a22e7dbab57ca5cb4b4d2cfa2e1 to your computer and use it in GitHub Desktop.
[WordPress] Add ACF Admin Column to taxonomy (In this example, taxonomy name = product_category & ACF column name = english_name)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add ACF Columns | |
function add_new_product_cat_column($column) { | |
$column['english_name'] = 'English Name'; | |
return $column; | |
} | |
add_filter('manage_edit-product_category_columns', 'add_new_product_cat_column'); | |
function add_new_product_cat_admin_column_show_value( $content, $column_name, $term_id ) { | |
if ($column_name == 'english_name') { | |
$content = get_field('english_name', 'product_category_' . $term_id); | |
return $content; | |
} | |
return $content; | |
} | |
add_filter('manage_product_category_custom_column', 'add_new_product_cat_admin_column_show_value', 10, 3); |
I've added this :
function sort_new_product_cat_column($column) {
$column['english_name'] = 'english_name';
// ^^^^^^^^^^^^^
return $column;
}
add_filter('manage_edit-product_category_sortable_columns', 'sort_new_product_cat_column');
// ^^^^^^^^^
The new column is clickable, but the sorting is wrong
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can I make it sortable ?
Thanks 👍