I first learned about the Simple Page Ordering plugin during Helen Hou-Sandi’s session at this year’s WordCamp San Francisco, which I “attended” virtually via live stream. Her session was called “Custom Tailoring the WordPress Admin Experience,” and you can, and should, watch it here on WordPress.tv.
I’m on a constant quest to make the WordPress admin easier and more intuitive for my clients to use, and Simple Page Ordering is now a key part of that strategy. If you’re not familiar with it, this plugin allows you to order and re-order your pages and other hierarchical post types with a simple drag and drop interface in the page or custom post type list.
But that simplicity also presents a problem: I don’t want my clients, or most of them, to be able to rearrange their pages so easily, as this can have undesirable results. Let them rearrange slides, staff, and other custom post types to their heart’s content, but not pages. At least not with a more concentrated effort, anyway.
So a couple months after I first implemented Simple Page Ordering into my websites, I finally had a small window of time this morning to tackle this problem, and the code below is what I came up with.
Add a filter
Gist – Filter Simple Page Ordering to exclude Pages but include custom post types that are hierarchical but don’t have page attributes
Where to put this code:
Add the code to a core functionality plugin, its own plugin, or functions.php.
What this code does:
We’re using a filter to tell the Simple Page Ordering plugin to only sort post types that are hierarchical but don’t have page attributes. This is going to exclude pages, and include each custom post type that has ‘hierarchical’ set to true, and ‘supports’ does not list ‘page-attributes’ in its array.
Not having page attributes means that you won’t be able to set a Parent for a post type even though it is hierarchical, but since I’m dealing with custom post types that typically don’t need this feature, I don’t see this as a problem.
The following screenshot shows a list of Slide custom post types from one of my demo sites that are being rearranged using the Simple Page Ordering plugin.