Created
May 13, 2026 11:16
-
-
Save abidkakkur11/c6c6275437340244eca6d5acd742760a to your computer and use it in GitHub Desktop.
This snippet will add short description and description on the woocommerce all products page
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 Description & Short Description columns to WooCommerce product list | |
| add_filter( 'manage_product_posts_columns', function( $columns ) { | |
| $columns['short_description'] = __( 'Short Description', 'woocommerce' ); | |
| $columns['full_description'] = __( 'Description', 'woocommerce' ); | |
| return $columns; | |
| }); | |
| add_action( 'manage_product_posts_custom_column', function( $column, $post_id ) { | |
| $product = wc_get_product( $post_id ); | |
| if ( $column === 'short_description' ) { | |
| $text = $product->get_short_description(); | |
| echo '<div style=" | |
| width: 180px; | |
| max-height: 80px; | |
| overflow-y: auto; | |
| font-size: 12px; | |
| line-height: 1.4; | |
| white-space: normal; | |
| word-break: break-word; | |
| ">' . wp_kses_post( $text ?: '—' ) . '</div>'; | |
| } | |
| if ( $column === 'full_description' ) { | |
| $text = $product->get_description(); | |
| echo '<div style=" | |
| width: 220px; | |
| max-height: 80px; | |
| overflow-y: auto; | |
| font-size: 12px; | |
| line-height: 1.4; | |
| white-space: normal; | |
| word-break: break-word; | |
| ">' . wp_kses_post( $text ?: '—' ) . '</div>'; | |
| } | |
| }, 10, 2 ); | |
| // Fix column header widths via CSS | |
| add_action( 'admin_head', function() { | |
| $screen = get_current_screen(); | |
| if ( $screen && $screen->post_type === 'product' ) { | |
| echo '<style> | |
| .column-short_description { width: 200px !important; } | |
| .column-full_description { width: 240px !important; } | |
| .column-short_description div::-webkit-scrollbar, | |
| .column-full_description div::-webkit-scrollbar { | |
| width: 4px; | |
| } | |
| .column-short_description div::-webkit-scrollbar-thumb, | |
| .column-full_description div::-webkit-scrollbar-thumb { | |
| background: #c3c4c7; | |
| border-radius: 4px; | |
| } | |
| </style>'; | |
| } | |
| }); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment