Profile picture for user admin
Daniel Sipos
03 Feb 2014

In this article I am going to show you a quick trick that will allow you to assign taxonomy terms to a lot of nodes all at once. For this we will use Views and Views Bulk Operations and will require no coding whatsoever. So let's begin.

First off, make sure you have the 2 modules installed. Drush will quickly take care of that for you if you don't have them yet:

drush dl ctools views vbo && drush en ctools views views_ui vbo

Now, the next thing we need to do is create a View page that displays the content (nodes, users, etc) you'd like to operate on in bulk (in our case, add taxonomy terms to). Make sure it uses fields and for start, the title field will be enough. For filtering, use whatever you need to filter the View to show only the content you want and sorting doesn't really matter.

Next up, add a new field of the type: Bulk operations: Content. This will provide next to the node title a checkbox for you to select that node to be part of the bulk operation.

To configure this field, make sure you check the boxes Modify entity values and Show available tokens followed by selecting the values of which field you'd like changed (in our case the taxonomy term reference field). In the screenshot below, you can see my selection for the Tags field of the Article node (I am going with a node view displaying articles).

Now you can save the View and navigate to its page. In the image below you can see my example. A table formatted view with the checkbox and the Article node title to its right. And the VBO operations above it.

Now, let's say I want to apply a taxonomy term to all these nodes. I can select them all (either manually or using the top-most checkbox dedicated for selecting all rows at once), choose my operation (Modify entity values) and click Execute. And this is then my next screen:

I have an autocomplete widget (like the default Article content type Tags field referencing taxonomy terms) where I can select one or more terms I'd like applied to all those nodes. I also have an option to ensure that existing values do not get overriden, by checking the respective checkbox. And lastly, I have some tokens available to use (because of the Tokens module).

Once I select my terms and press Next, I get an overview of how many nodes are going to be affected by this change (as you can see below). And that's basically it.

One thing to keep in mind here. If you are adding a non already existing taxonomy term, VBO will create that term as many times as the number of nodes being processed. So you'll end up with a bunch of terms with the same title. Probably not something you either expect or want. I therefore recommend you create your term before and then apply it to the content.

Hope this helps!

Profile picture for user admin

Daniel Sipos

CEO @ Web Omelette

Danny founded WEBOMELETTE in 2012 as a passion project, mostly writing about Drupal problems he faced day to day, as well as about new technologies and things that he thought other developers would find useful. Now he now manages a team of developers and designers, delivering quality products that make businesses successful.

Contact us

Comments

nordic material 05 Feb 2014 02:33

Good intro to bulk operations

Nice introduction, encourages me to use views bulk operations more often from now on. Warning about the 'creating term as many times as the number of nodes' very useful. Thank you for sharing.

martin 11 Feb 2014 09:46

vbo progress bar

Thanks. Great article, is there a way to disable the progressbar after vbo executes

Tharick 28 Apr 2015 11:59

In reply to by martin (not verified)

You can give "Skip

You can give "Skip confirmation step", so you wont see the progress bar.

yukiko 10 Mar 2014 22:46

How to delete?

thanks!

I can do these things thanks to your article.
but I cannot delete the terms from node...

In drupal6 ,the radio button of deleting terms was appeared under the adding checkbox.

Any suggestions?

criscom 27 Jun 2014 12:56

Batch without recreating the URL aliases

Thanks, great tutorial! When I run the patch, the URL aliases are automatically regenerated although the checkboxes in the indivdual nodes (Generate automatic URL alias) are unchecked. This changes the URLs of each node, which I don't want. I haven't figured out how to run the patch without automatically regenerating the URL aliases. Any ideas?
Thanks!
Chris

criscom 27 Jun 2014 13:24

Workaround for automatic alias patterns

If you have automatic alias patterns activated (autopath) then you have to temporarily remove the alias pattern from the settings. Also remove the default pattern so that no pattern applies for the Content Type in question. Thus the URL pattern will remain untouched when applying the patch with VBO

nithinkolekar 27 Jul 2015 12:25

Also it will create dupe

Also it will create dupe terms when tokens are used instead of normal text. I thing token support itself should be removed while assigning term value.

DaveFletch 31 Oct 2015 23:38

Dupes bug makes this so awkward

Also I think the default should be to append not overwrite. "Bulk tagging" doesn't seem to imply "delete some of the tags" to me in any way, the first time I tried it without ticking the box the behavior was a surprise. Hope these can get fixed up, I'll probably try to hack on some fixes so I don't have to explain this awkwardness to other admins.

Debashree Dhara 14 Oct 2016 10:17

Its really helpful

I am just looking for the same for my project work.

nithinkolekar 27 Jun 2017 16:49

clear taxonomy term?

I am trying to clear taxonomy terms fields value from multiple node by selecting particular field and leaving blank that field but term values are still present.
do you know how to clear taxonomy term in bulk?

AE 19 Jul 2017 21:14

Hi there. For some reason VBO

Hi there. For some reason VBO is not taking the changes. Once selected the flied and executed the command, nothing happens. Thoughts on this pls? Thanks for your great work with Drupal. Much appreciated.

MIDRC 14 Dec 2019 02:54

Thank you

After migrate a site from Joomla to Drupal 8 i have a big list of term with your tuto it's so easy :)

On drupal 8.8 for change term in node i must have to use Views Bulk Edit module

Thank you very much

Add new comment