# Menu Order Shuffler (WordPress Snippet)
A lightweight WordPress snippet that enables the native menu ordering functionality across all public post types, including WooCommerce products, allowing custom drag-and-drop ordering through WordPress admin.
Purpose
WordPress by default only allows page ordering. This snippet extends menu ordering to:
- All custom post types
- WooCommerce products
- Custom post types that don't support page-attributes
Implementation
php
// Enable menu_order support for all public post types
add_action('init', function () {
$post_types = get_post_types(['public' => true], 'names');
foreach ($post_types as $pt) {
if (!post_type_supports($pt, 'page-attributes') || $pt === 'product') {
add_post_type_support($pt, 'page-attributes');
}
}
});Usage
- Add to theme's functions.php or use with a snippet plugin
- Go to any post type list in admin
- Use the "Order" column to drag and reorder
- Changes reflect on the frontend based on menu_order
Post Types Affected
- Posts
- Pages
- WooCommerce Products
- Custom Post Types
Additional Features (from full snippet)
- Column visibility toggle
- Bulk order reset
- Custom order display
- Quick edit support
Architecture Feedback
Spotted a potential optimization or antipattern? Let me know.