In a category group "Shops & Services" we have three parent categories each with many sub-categories:

  • Offices
  • Services
  • Retail

The Retail (parent category) has grown to a point where it needs to become its own category group. In the end we will have these groups:

  • Offices & Services
  • Retail

Is there a best method for doing this? There are quite a few entries here so manually updating each individual entry would be daunting. Would it be as simple as running a SQL query?


1 Answer 1



Since you would probably prefer to truly just move an existing category to a new group (and not create new ones and reassign entries as outlined below), this SQL is all you would need:

UPDATE exp_categories
SET group_id = X
WHERE cat_id = Y OR parent_id = Y

X = new category group
Y = parent category that you want to move to new group

The OR clause will catch and move the child categories to the new group as well. Remember to make a backup first.

The edit page in the CP does include an option to filter entries by category and then mass-assign a new category. I've used this to do exactly what you've described.

  1. Filter by your old category to get the entries
    enter image description here

  2. Select (check) all entries,
    then choose "Add Categories" bulk action from the menu on the bottom right
    enter image description here

This is practical if you don't have too many entries that need systematic recategorization (say a few hundred). Just set the limit on the edit page search to 150 entries so you mass-apply categories to a larger batch at each pass.

Otherwise, yes, SQL is the way to go. Just create your new category and note its ID. Then run the following query (backup your database first):

UPDATE exp_category_posts
SET cat_id = X
WHERE cat_id = Y

X = the new category ID
Y = the old category ID

  • I updated my answer with SQL in case you prefer that route.
    – Alex Kendrick
    Commented Dec 5, 2013 at 17:26
  • I updated my answer again (see the top) since I realized I probably missed the mark. If this still falls short in some way let me know.
    – Alex Kendrick
    Commented Dec 5, 2013 at 21:43
  • Hey Alex, this looks ideal. Let me try this at some point and I will mark you as the answer! Thanks!! Commented Dec 6, 2013 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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