Skip to main content

Taxonomy Management Tasks

These tasks manage WordPress taxonomies (tags and categories), allowing you to remap or delete them individually or in bulk.

TaxonomyRemapTask

Class: Maintenance::Wordpress::TaxonomyRemapTask

Remap or delete a single WordPress taxonomy. When remapping, all posts with the source taxonomy get the destination taxonomy added before the source is deleted.

Parameters

ParameterTypeRequiredDefaultDescription
localestringYes-WordPress site locale (e.g., en, fr, it)
taxonomystringYestagsEither tags or categories
source_identifierstringYes-The term_id (numeric) or slug of the source taxonomy
destination_identifierstringConditional-Required for remap operations
delete_onlybooleanNofalseDelete without remapping posts

Operation Modes

Remap Mode

When destination_identifier is provided and delete_only is false:

  1. Finds all posts with the source taxonomy
  2. Adds the destination taxonomy to each post
  3. Deletes the source taxonomy

Delete Only Mode

When delete_only is checked:

  1. Deletes the source taxonomy directly
  2. Posts that had this taxonomy lose it (no remapping)

Examples

Remap tag by term_id:

locale: en
taxonomy: tags
source_identifier: 123
destination_identifier: 456
delete_only: false

Remap category by slug:

locale: fr
taxonomy: categories
source_identifier: old-category-slug
destination_identifier: new-category-slug
delete_only: false

Delete tag without remapping:

locale: it
taxonomy: tags
source_identifier: unused-tag
delete_only: true

Validation Rules

  • locale must be present and in I18n.available_locales
  • taxonomy must be either tags or categories
  • source_identifier is always required
  • Cannot specify both delete_only and destination_identifier
  • destination_identifier is required when not using delete_only

BulkTaxonomyRemapTask

Class: Maintenance::Wordpress::BulkTaxonomyRemapTask

Process multiple taxonomy operations from a CSV file. Each row can specify a remap or delete action.

Parameters

ParameterTypeRequiredDefaultDescription
localestringYes-WordPress site locale
taxonomystringYestagsEither tags or categories
CSV FilefileYes-CSV with taxonomy operations

CSV Format

The CSV must have these columns:

name,slug,term_id,count,action
ColumnDescription
nameDisplay name of the taxonomy (informational)
slugURL slug of the taxonomy (informational)
term_idWordPress term ID used for identification
countNumber of posts using this taxonomy (informational)
actionOperation to perform (see below)

Action Column Values

ValueOperation
Numeric (e.g., 456)Remap to taxonomy with this term_id
delete or RDelete without remapping
Empty or otherSkip this row

Example CSV

name,slug,term_id,count,action
Old Tag,old-tag,123,45,456
Unused Tag,unused-tag,124,0,delete
Typo Tag,typo-tag,125,10,R
Keep This,keep-this,126,100,

In this example:

  • Row 1: Remaps term 123 to term 456
  • Row 2: Deletes term 124 (using delete)
  • Row 3: Deletes term 125 (using R)
  • Row 4: Skipped (empty action)

How It Works

The bulk task enqueues individual TaxonomyRemapTask runs for each actionable row:

Workflow

  1. Export taxonomy list using ExportTaxonomyTask
  2. Open CSV and add an action column
  3. Fill actions for each taxonomy you want to modify
  4. Upload the modified CSV to BulkTaxonomyRemapTask
  5. Monitor individual TaxonomyRemapTask runs in the UI

Performance Considerations

Each row with an action enqueues a separate maintenance task. For large operations:

  • Tasks run asynchronously in the background
  • Monitor progress in the maintenance tasks UI
  • Individual task failures don't affect other rows