Are WordPress Shortcodes Good for Admin UI Design?

With a degree in computer information systems from Mohawk Valley Community College, John worked for small businesses and performed freelance work before joining Site-Seeker in 2007.

In this series I’ve been talking about Admin User Interface (UI) Design in WordPress. In my first post I went over the importance of good admin UI design and next I talked about custom post types and taxonomies. In my last post I discussed custom fields.

In this next installment I want to talk about shortcodes.

What are Shortcodes?

A shortcode in WordPress allows the addition of content to a page by simply including the shortcode tag in the content. A shortcode tag consists of a short identifying piece of text and maybe some parameters enclosed in square brackets, something like this [myShortcode a=”2” b=”X”].

For example, there is a built in shortcode that allows editors to simply and easily add a photo gallery to a page. You simply type the tag (I was going to put the gallery tag in here to show you what it looks like, but apparently there isn’t a way to do so without it turning into a gallery. You can read about it here.) into the content area, save your changes and an interface will be added to the content editor that will allow you to insert images.

Sounds like a great idea, doesn’t it? I would agree if every short code did the same thing, that is, added an interface within the content editor to edit the content that the shortcode displays, but this isn’t the case.

The Problem with Shortcodes

Shortcodes are great for developers. It means they can create a plugin and define a shortcode in that plugin so that when WordPress finds it in the content it will call the developers plugin function to supply the proper content to replace the shortcode tag with. In fact many developers love them, but I don’t think their clients would agree, I certainly don’t.

I want to clarify something at this point. Shortcodes can also be used in theme templates by the developer. This is not the use I’m talking about here. Shortcodes used in templates by the developer make it easier for the developer to build a site and I have nothing against this use. My problem is requiring the client to use them in the Admin UI.

Imagine the following scenario, and just in case you’re wondering, this is not fictitious but a site that I have actually had to deal with, inherited from another developer. On this particular site there are 3 different plugins used that each allow you to add different things to the content area using shortcodes. One of them allows you to create tables, another allows you to show different content to different types of users, and another adds a photo gallery, this is not the built in gallery shortcode, but a separate one, which makes one wonder why it was needed in the first place and why the standard Gallery wasn’t used. The site has no less than 100 pages, each page has 4 different tables that are associated with it that are built in the table plugin, one table for each of the 4 different types of users. That means that there are at least 400 different tables stored separately from the pages of this site. There is at least one photo gallery for every page, and sometimes more. This means there is at least 100 different photo galleries, also stored separately from the page.

With the above in mind, the content editor of the site looks something like this:

I have altered the tags in the above so I don’t point the blame directly at any plugin in particular. I just want to point out the problem as I see it. The content of this page needs to be edited in at least 6 different places. There is this content field as well as the need to hunt down each of the 4 tables and the gallery plus you need to make sure that you know what each of the user type values is associated with.

If your using this for your own site and you understand and want to do this, that’s one thing, but this is not something you should never give to a client that wants to maintain their own site. This is not user friendly in any way, shape or form.

Imagine that you are the client and you only edit your site about every 2 to 4 weeks and sometimes may not look at the site for months. You basically need to relearn what this means every time or even learn it the first time if you’ve just inherited the editorship. I can tell you how this client feels, frustrated and angry. They were sold a CMS so that they could easily edit the content of their site and they are unable to do so. Instead, because it requires too much of their time to relearn how to edit the content and make the changes they instead need to have a developer do the work.

As far as a tool for developers, shortcodes where a great idea, but in my opinion they were implemented poorly as far as making an intuitive, user friendly UI goes. Yes, the client can just call the developer to have changes made, but then why did they bother to use a CMS? It defeats the number one purpose of using a CMS, which is to make it easy for non-technical personnel to manage a Web site.

This same thing could have been accomplished using custom fields which would have kept all the editing on a single page instead of needing to find and navigate to 7 different admin pages to make changes. Would it have taken more time to build it that way, definitely, but in the long run the cost of maintenance would have been much lower. For more information on using custom fields see my post on the subject.

Conclusion

I’m not a big fan of using shortcodes in the editor as they are currently implemented. Like I said above, there is almost always a better way to do whatever you plan to do with shortcodes. While the principle of shortcodes may be a good one the implementation is poor. Developers use them as a shortcut to creating an intuitive interface and using them generally means the editor will need to go to several places to edit the content of any one page. In the end they reduce the maintainability of a large site and in my opinion shortcodes are one of the built in WordPress features that should be avoided. The only exception to this are shortcodes that are built into the WordPress core that allow you to edit content directly in the content editor rather than needing to edit it elsewhere (like the gallery shortcode). Now if plugins could use this same ability to allow their shortcode content to be edited right in the on page content editor that would be something to talk about. It may even be possible, after all, WordPress does it with the built in shortcodes, however it is probably well beyond the ability of most plugin developers at this time.