Skip to content

Instantly share code, notes, and snippets.

@aguilar1181
Last active July 10, 2019 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aguilar1181/af914601a668e10dd256 to your computer and use it in GitHub Desktop.
Save aguilar1181/af914601a668e10dd256 to your computer and use it in GitHub Desktop.
Woocommerce Custom Colums from Custom Fields
<?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