I am using Events Calendar Pro and due to a bug multiple Venue taxonomies were created. For example, I have museum, museum-2, etc. I would like to delete the duplicates but assign the event associated with the duplicate venue to the 'main' venue. Is there a find/replace I can use that would do this for me? Other suggestions are welcome. Thank you.
I am using Events Calendar Pro and due to a bug multiple Venue taxonomies were created. For example, I have museum, museum-2, etc. I would like to delete the duplicates but assign the event associated with the duplicate venue to the 'main' venue. Is there a find/replace I can use that would do this for me? Other suggestions are welcome. Thank you.
You could just run DELETE FROM wp_terms WHERE slug LIKE "museum-%"
on you MySQL server, but that would probably leave some orphan rows in wp_term_taxonomy
and potentially in wp_term_relationships
if you have used the terms. While being a bit more complicated I would recommend deleting them using the WordPress API. Something like this might work (from memory, so I'm not 100 percent on the usage of the term_
prefix in $term->term_slug
and $term->term_id
):
$terms = get_terms(array('your_term'), array('name__like' => 'Museum'));
foreach ($terms as $term) {
if (term->term_slug != 'Museum') {
wp_delete_term($term->term_id, 'your_term');
}
}
It's apparently not possible to search for terms by slug, so be carful not to delete terms like "Museums" or "Museum of Natural History" which will happen if you run the above code.