Last active
July 10, 2019 20:59
-
-
Save aguilar1181/af914601a668e10dd256 to your computer and use it in GitHub Desktop.
Woocommerce Custom Colums from Custom Fields
This file contains 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 custom columns to admin page | |
add_filter( 'manage_edit-product_columns', 'show_product_order', 15 ); | |
function show_product_order($columns){ | |
$columns['COLUMN_NAME'] = __( 'LABEL'); //Add this for each new column and change LABEL and COLUMN_NAME | |
return $columns; | |
} | |
//Get Custom Columns values from fields | |
function custom_columns( $column, $post_id ) { | |
//Add this block for each column created above | |
if ( $column == 'COLUMN_NAME' ) { | |
echo get_post_meta( $post_id, 'CUSTOM_FIELD_NAME', true ); //Change CUSTOM_FIELD_NAME | |
} | |
} | |
add_action( 'manage_product_posts_custom_column', 'custom_columns', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment