How Bulk Actions Help Your Users in WordPress


One of the things I like the most about WordPress is its plugin system–there's a lot you can do! For instance, you can download and install our new plugin, Nelio Content.

I’ve always believed that good developers automate any task they have to do more than once. And you know what? If you try to automate as many of your tasks as possible, you might get lucky and never work again some day 😜  (which is a quite convincing argument, isn’t it? 😇). I’m already on my way to early retirement and, for example, I’ve recently created a tiny script that simplifies the process of releasing new versions of our plugins.

As a WordPress plugin developer, your task should also be to make the life of your users easier. You can achieve this, of course, by creating a plugin that literally automates their tasks (such as we do with Nelio Content, which fully automates the promotion of their WordPress blog on social networks). But making lifes easier is not only about automations; you can also save your users work if you simplify their tasks, reducing, for example, the number of steps needed to complete them. And this is exactly what I came to talk to you about today.

A couple of years ago I wrote a post on how to create your first plugin in WordPress. I explained to you, step by step, how we could put a box on the edit post page to add extra information to your post. Well, today we’ll see what we can do to simplify life for our users and improve their performance when using our plugins.

Let’s Get Started—Simple Plugin with One Meta Box

Imagine we have a plugin like Nelio Content that reshares your blog’s content in social media. The users may be interested in certain posts not being automatically reshared, so they need some mechanism to tell the plugin what can or can’t be shared. For the sake of simplicity, we’ll assume this can be done by using a checkbox in a custom meta box:

Reshare checkbox in custom meta box
Checkbox in a custom meta box to exclude a certain post from being automatically reshared.

If the user checks the box, the post won’t be automatically reshared. If it’s unchecked, then our plugin will be able to reshare it whenever it feels like it. Easy peasy, right?

Users Should Drive All Your Decisions

If we’re to make our users’ lifes easier, the first thing we have to do is identify the tasks that need simplifying—that is, those that are the most labor-intensive. In my example, such a task is clearly the process of configuring which posts can or can’t be reshared. Let’s take a closer look at this.

Identify the Problem

The user’s goal is to easily define which posts should or should not be reshared by the plugin. Unfortunately, the current version of our mock plugin requires the following steps for changing the reshare option of a single post:

  1. Find the post in the All Post list
  2. Click on the Edit link
  3. Wait until the Edit Post screen is loaded (which might take a few seconds)
  4. Scroll down and look for the plugin’s meta box
  5. Click on the checkbox to toggle its value
  6. Scroll up and look for the Publish box
  7. Click on Save

Boring, right? 😩 Then remember this: your users have to do that every time they want to change a single post! Damn 😭

Possible Solutions

Once we know the problem we want to tackle, it’s time to think about possible solutions. For example, from the top of my head:

  • Use the fact that posts are organized into tags and categories and use them to define what should be shared. For instance, with the proper UI, we’d be able to tell our plugin: “share all posts in WordPress, and don’t share any in Business“.
  • Using Bulk Actions in WordPress, we can add the checkbox directly in the All Posts list and modify the reshare option in more than one post at a time.

When considering multiple solutions, remember that they all have some pros and cons. You’ll have to choose the best option keeping your users in mind. In this particular case, I’d probably choose the second option: the checkbox is something our users already know (they’re used to seeing it in the meta box) and they perfectly understand how it works. Besides, adding it in the Bulk Edit is a straight-forward process. Conversely, the first solution I thought of is way more complex—sure, it’d be also more flexible, but it’d also be more difficult to implement and more complicated to use.

How to Add New Bulk Actions in the All Posts List

Adding new Bulk Actions in WordPress is actually pretty simple. Just follow these four easy steps:

  1. Add a new column in the Posts list. This might seem unnecessary, but we have to because Bulk Actions can only modify attributes that are in the list.
  2. Add the proper values in the new column.
  3. Add the checkbox in the Bulk Edit form.
  4. Tweak WordPress to make sure that the value is properly saved when the user submits the Bulk Edit form.

If you do it properly, you’ll have this:

New Bulk Action in the Bulk Edit form
Screenshot of the Bulk Edit form in WordPress containing a new bulk action at the end.

Adding a New Column in the All Posts List

This step is very simple—just hook into the manage_posts_columns action and, for each post type you’re interested in, add the new column:

Set the Proper Values in the New Column

In this case, we’ll use an action named manage_posts_custom_column. The callback function receives two params, the column for which we’re setting the value and the related post ID. The code is very simple too: we simply need to make sure we’re setting the value of the column we just created (lines 6 to 8) and, if everything’s OK, output the specific value the current post has (lines 10 to 14):

Adding the Checkbox in the Bulk Edit Form

Once again, we use WordPress’ filters and actions to get the job done. This time, we hook into bulk_edit_custom_box and simply output the form field we want:

Now, did you notice I didn’t print a checkbox, but a select? You might be wondering why I did that… and the answer is pretty simple: checkboxes have a binary state (either they’re checked or they aren’t). In bulk actions, however, you usually want a third state, which is “don’t change anything, leave the values as they are”. So, in order to do that, I have to print a field with three values—a select.

Save the Value (Probably)

Last, but not least, we have to make sure that whatever the user selected value is, it is saved into the database. This can be easily achieved by using the save_post action. The callback function simply need to retrieve the user’s input from the $_REQUEST array and, depending on its value, update the database:


Today we’ve seen how easy it is to add Bulk Actions in WordPress, and how helpful they are! But beware, don’t be tempted to use them all the time—we decided to use this solution after we identified a problem and carefully decided it was the best solution possible. You should also follow this reasoning when facing a similar issue.

So, remember, simplify or automate the boring stuff and your users will love you.

Featured Image by Iker Urteaga on Unsplash.

PoorMehGoodVery GoodAwesome! (No Ratings Yet)


He obtained his PhD in Computer Science at UPC. David leads the analysis and design of our services and the user support area. He's interested in a variety of areas, including conceptual modeling, virtual reality, and 3D digital printing. He contributes to the WordPress community by participating in meetups, seminars, and the WCEU.

Leave a Reply

Your email address will not be published. Required fields are marked *