Blog

Adding a Separator to the WordPress Admin Menu

August 7, 2012

Custom Post Types in WordPress are superb! More often that not, websites that we build for clients have more than one custom post type which inevitably will clutter up the admin menu slightly. The solution to the problem is one that WordPress itself employs: De-clutter the meny by inserting a separator in between sections.

Doing this requires just a couple of simple PHP functions that you can add to your functions.php file. One to create the separator, one to add any number of separators at any position in the menu and finally an action hook into the menu to add it.

Creating the Admin Menu Separator

The following code is used to create a function that creates the separator itself. Note that the position of the separator in the menu is passed as a variable into the function so that the function can be repeated for more than one separator, at any position.

The Complete Code

Here are both functions put together. Just place this in your functions.php file in your theme or use in your plugin to easily create a custom separator to organize those custom post types or menu pages.

This is exactly what I’ve been looking for. But it seems to not be working for me as intended. I am also using the Jetpack plugin on my site which is placed between Dashboard and a divider per default. When I add your code the Jetpack divider and the new divider get placed where I chose the new one to be. If that’s really confusing I’ve attached a photo. Any thoughts?

http://www.xldstudios.com/ Erik Bernskiöld

I have seen the same problem myself at times with some other plugins too, but I am afraid I don’t quite know the answer as to how to fix it.

JD

Thank you, this was very helpful!

XLD Studios is a WordPress web agency who builds and maintains beautiful WordPress websites for clients around the world. Read More