1

How would you programmatically add a taxonomy term to an already created content type? Presupposing that I already have the taxonomy field available on all the selected content-types beforehand.

I wish to bulk add a taxonomy term to several nodes. I noticed in the content display list there is a way to filter down to a term when it already exists on nodes, but is there a way to possibly add it to a content-type that doesn't have it yet?

I read the question and comments for

Programmatically create a taxonomy term

and this is partially there, but I don't know how to get it further.

3

You should check out the Views Bulk Operations (VBO) module. It allows you to create a View to generate a list of target nodes (or other things like Users) and perform an action on each of those nodes. One fo the available actions is modifying the taxonomy terms used on these nodes. This is actually the exact example used in the documentation for VBO on d.o. It seems like this is exactly what you're looking to do, just not actually programmatically. Maybe that's ok... but if not, you can create this VBO and then execute it programmatically using views_bulk_operations_execute.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.