Created
June 13, 2019 06:39
-
-
Save imran-khan1/d3f6026ec233ad5f501f2a8203e72e6e to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Add new "Manufacturer" column to products list | |
*/ | |
add_filter( 'manage_edit-product_columns', 'add_product_manufacturer' ); | |
function add_product_manufacturer( $columns ) { | |
$columns['meta_box_manufacturer'] = 'Manufacturer'; | |
return $columns; | |
} | |
/** | |
* Output "Manufacturer" column | |
*/ | |
add_action( 'manage_product_posts_custom_column', 'render_product_column_manufacturer', 2 ); | |
function render_product_column_manufacturer( $column ) { | |
if ( 'meta_box_manufacturer' != $column ) { | |
return; | |
} | |
$manufacturer = get_post_meta( get_the_ID(), 'meta_box_manufacturer', true ); | |
echo $manufacturer; | |
} | |
add_action('admin_head', 'manufacturer_column_width'); | |
function manufacturer_column_width() { | |
echo '<style type="text/css">'; | |
echo '#meta_box_manufacturer { text-align: center; width:100px !important; overflow:hidden }'; | |
echo '</style>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment