Setting default Order of Products in Admin
-
Hi,
I have added the below code to my functions.php file to add an additional column which is sortable but my client wants the products to appear in the menu order by default when viewing the Products screen. Does anyone know how we can do this?
// Register the column for menu order function bf_menu_order_column_register( $columns ) { $columns['menu_order'] = __( 'Menu Order', 'mytextdomain' ); return $columns; } add_filter( 'manage_edit-product_columns', 'bf_menu_order_column_register' ); // Display the menu order column content function bf_menu_order_column_display( $column_name, $post_id ) { if ( 'menu_order' != $column_name ){ return; } $menu_order = get_post_field('menu_order', $post_id); if ( !$menu_order ){ $menu_order = '' . __( 'undefined', 'mytextdomain' ) . ''; } echo $menu_order; } add_action( 'manage_posts_custom_column', 'bf_menu_order_column_display', 10, 2 ); add_action( 'manage_product_custom_column', 'bf_menu_order_column_display', 10, 2 ); // Register the menu order column as sortable function bf_menu_order_column_register_sortable( $columns ) { $columns['menu_order'] = 'menu_order'; return $columns; } add_filter( 'manage_edit-product_sortable_columns', 'bf_menu_order_column_register_sortable' );
Thanks,
James Isles
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Setting default Order of Products in Admin’ is closed to new replies.