Using pathauto module, I know we have a Delete aliases tab to delete URLs in bulk but what if we need to delete URLs of all terms for specific vocabulary?
Any idea how to do that?
Using pathauto module, I know we have a Delete aliases tab to delete URLs in bulk but what if we need to delete URLs of all terms for specific vocabulary?
Any idea how to do that?
To delete the aliases you will need a custom module or perhaps a custom VBO action based on the update taxonomy term alias
action. Here is a quick and dirty version of a custom module
aliases_delete.info
name = delete aliases
description = will delete vocabulary aliases for specific vocabulary
package = aliases_delete
version = 1
core = 7.x
dependencies[] = pathauto
aliases_delete.module
<?php
function aliases_delete_menu() {
$items['aliases_delete/%'] = array(
'page callback' => 'aliases_delete_delete_vocabulary',
'page arguments' => array(1),
'access callback' => 'taxonomy_term_edit_access',
'access arguments' => array(2),
);
return $items;
}
function aliases_delete_delete_vocabulary($vocabulary_name){
$vocab = taxonomy_vocabulary_machine_name_load($vocabulary_name);
$terms = entity_load('taxonomy_term', FALSE, array('vid' => $vocab->vid));
foreach ($terms as $term) {
pathauto_entity_path_delete_all('taxonomy_term', $term, "taxonomy/term/{$term->tid}");
}
return 'Deleted aliases of all terms in ' . $vocabulary_name;
}
If you enable and install this module you can visit as admin aliases_delete/tags
to delete all aliases of terms in vocabulary tags
To update the path aliases of specific taxonomy terms (instead of deleting) you can use VBO - views_bulk_operations
update taxonomy term alias
action and press execute
taxonomy/term/[term:tid]
the action does not change/update the ALIAS ... what are you looking to achieve ? ... put a specific pattern and it will work
taxonomy/term/[term:tid]
is a core pattern while I was talking about the admin/config/search/path/patterns like in the image. When I empty these patterns and update as you answered it doesn't update. My ideal achievement is to delete aliases that created by pathauto module.
Commented
Mar 26, 2018 at 10:55