In this post I’ll share some User Experience hacks and useful functions for the WordPress backend, without the need of external plugins.
By simply using your
, you will be able to do a number of cool things.
There are a lot of common ways to customize WordPress default screen and functions, but I will go over some specific cases that I worked on for some clients, that you won’t find elsewhere online.
You should also have a look at my selection of MUST-HAVE plugins for WordPress!
1. Add Cache & Transients Flush buttons to Top Bar
We should all enable some caching system (preferably object caching like memcached, but static files will work too), as well as saving all queries to carefully crafted transients, in order to optimize pageload performance and rely less on the database.
This snippet will place 2 new buttons in your admin bar, that will allow you to quickly flush all persistent caching (if you are using it, otherwise it won’t show up) or just the transients (whether they are saved to database or not). It will also display a message once done.
There are of course solutions like WP Super Cache, Bat Cache or W3 Total Cache that will take care of everythin for you already, but you might want to use your custom lightweight solution instead (like me).
2. Automatically rename Post Slug on save
Sometimes, you might want to automatize certain processes that would normally require at least 2 more clicks, or an additional interaction by the user.
This snippet makes sure that if the title of the post changed during editing (in editing screen), also the slug will update automatically (normally this doesn’t happen and the user would have to remember doing it manually).
3. Automatically re-assign Post Author on save
This is a similar automatization process, like for post slugs.
By default, a post author will be the one who created it and anyone that edits it after that, won’t be visible anywhere (nor will receive notifications, which was the very reason why I made this snippet).
4. Custom Column with Duplicate Post button and duplicates checker
This is a specific case where you may have created different custom post types, with the same content, but for different eg. Divisions.
So technically a post should be identical at first for all your Divions’ custom post types, but you don’t want to manually re-type in dozens of custom fields or taxonomies.
Existing plugins won’t work in this case (only works for the same post type at the moment), so this snippet will help you create an additional column that will display the custom post types you made, check if the post already exists in them and if not, allow you to quickly clone the current post in another custom post type.
We are also checking if the current user has the necessary Role/Permissions to perform this action, if not they won’t be able to clone the current post into another custom post type.
Finally, if the post already exists, but it hasn’t been published yet (Draft or Pending Review), the user will be able to quickly go edit it and publish it.
The snippet needs to be adapted to your needs of course, you can add as many custom post types you want, edit text and what not.
5. Clone Post as New or clone as a Child of current Post
This is an extension for the Duplicate Post function above.
It will add Action links in the Post list screen, as well as in the Edit Post screen.
You will now be able to clone a post in the same post type as a New Post, or as an identical Child of the current post…. in a click.
The snippet also check for user Role/Permissions, but that’s not required and it depends on your needs of course.
6. Make Post open in a new tab from the View link
This is an easy and quick fix if you want the default View link in the post action row, to display in a new tab, since by default WordPress opens it in the same window.
7. Hide Trash link depending on user and put it for last
This is a little UX hack, more than anything really, but since we’re at it… why not!
8. Display All Posts by default, not Mine
It might make sense for many WordPress sites, to display “My Posts” as the default Post list screen.
However there’s plenty of cases where this is not appreciated, now you can fix it easily.
9. Display children of Post in Edit Screen
Some WordPress sites heavily use children, depending on their structure and content.
Not everybody uses pages for this now, since hierarchical custom post types are possible too.
This snippet will create a box below the Post title Edit screen, with the list of children associated to it.
10. Order Post/Page List display by date
While default WordPress Posts do display chronologically, it appears that anything hierarchical (custom post types or pages) display in alphabetical order instead.
That may be inconvenient for some, hence this other UX hack.