updated: October 1st, 2015 / Ross Johnson / 3 Comments

Modifying WordPress Post/Page Quick Links (subsubsub menu)

If you’ve ever done any permission management that alters what posts, pages or custom post types users see then you’ve probably run into an issue where the quick links at the top of the admin page are inaccurate. You may also find that you want to edit, alter or extend these links (which was the case with Project Panorama.) There is surprisingly little documentation on how to filter these links, so after some head banging against the wall I figured out a solution.

Screen Shot 2015-10-01 at 9.54.06 AM

The Filter

You can alter the quick links by running a filter on ‘views_edit-post’. The filter can be customized for the post type by switching -post for -page or -custom-post-type.

For example:

Posts
add_filter('views_edit-post','your_function_name');

Pages
add_filter('views_edit-page','your_function_name');

Custom post type (movies in this case)
add_filter('views_edit-movies','your_function_name');

Like any filter, the second argument is your callback function which has one parameter containing an array with the quick links markup. So if you were modifying the quicklinks for your “movies” custom post type you’d have something like this:

The $views Array

The $views is a four item array containing the markup that will be output for the quick links. The items are:

$views['publish']

$views['draft']

$views['trash']

$views['pending']

Removing Submenu Links

Links can be removed by using unset, for example removing the link to the trash

Updating Post Counts

You can also alter the views by updating an individual item which was necessary for Project Panorama where some users could only see and access posts assigned to them. For example, if you were limiting the custom post type of “movies” to post authors you might do something like this:

This works great except the counts on the sub menu are not accurate.

So you’d want to add a second filter. Rather than rewrite a rather lengthy script, I found one that works great over on wpcustoms.

This loops through each post status (draft, published, trash, pending, etc…) and updates the count based on the author limited query.

Adding Links to the Sub Menu

You can also add links to the submenu, maybe you want a click link to display a specific category of movies.

That’s a Wrap

Little details like ensuring an accurate and useful sub menu in the editor is what makes WordPress stand apart from other cumbersome content management systems. Even though these details can take time they are worth implementing as it’s part of your craft. If you care about how nicely your code is formatted why wouldn’t you put that same attention to detail into the admin interface?

3 thoughts Modifying WordPress Post/Page Quick Links (subsubsub menu)

  1. Pingback: Modifying WordPress Post/Page Quick Links (subsubsub menu) | WordPress Coders - Articles

  2. Thanks for sharing such useful information with us. I was looking for this code from last weekend. even after trying, I wasn’t able to get it right .

    Cheers!!

  3. You’re very welcome, glad it helped you out!

    Ross Johnson

Comments are closed.