Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cristianstan/027eb591b928c3e6ae91cc90278a8e16 to your computer and use it in GitHub Desktop.
Save cristianstan/027eb591b928c3e6ae91cc90278a8e16 to your computer and use it in GitHub Desktop.
WP List Table: Column.php sortable custom field
<?php
// For iBid Auctions theme: https://themeforest.net/item/ibid-multi-vendor-auctions-woocommerce-theme/24923136
// WP List Table: Column
add_action('manage_product_posts_custom_column', 'ibid_show_columns');
function ibid_show_columns($name) {
global $post;
switch ($name) {
case 'shipping_country':
$shipping_country = get_post_meta($post->ID, '_shipping_country', true);
if (isset($shipping_country) && !empty($shipping_country)) {
echo $shipping_country;
}
break;
}
}
// Displaying the values
add_filter('manage_edit-product_columns', 'ibid_columns');
function ibid_columns($columns) {
$columns['shipping_country'] = 'Shipping Country';
return $columns;
}
// Sortable
add_filter( 'manage_edit-product_sortable_columns', 'ibid_sortable_date_column' );
function ibid_sortable_date_column( $columns ) {
$columns['shipping_country'] = 'Shipping Country';
return $columns;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment