I am trying to remove a string off of a bunch of slugs in terms from a CPT taxonomy slugs that were added and.
For example, I have a term named "Accounting" but the slug has the "accounting-expert-witnesses" I just need to get removedremove the "-expert-witnesses" part of the slug.
I'm tryingI am using this post as a reference as it appears to usebe what am I looking for but I cannot seem to get any of the suggestions to work: How to update taxonomy custom field with wp_update_term()?
I have tried using update_term_meta, update_post_meta, wp_update_term and none of them are doing what I need.
The closest I've got is using update_term_meta and it appears to be working when I error log the result however it does not appear to have worked when I viewlook at the terms throughin the dashboard? nothing has been updated.
I can't figure out what I'm doing wrong here?
function remove_stuff() {
$terms = get_terms( array(
'taxonomy' => 'experts_industries',
'hide_empty' => false,
) );
foreach($terms as $term) {
update_term_meta($term->id, 'experts_industries', array('slug'$newSlug =>= str_replace('-expert-witnesses', '' , $term->slug);
//update_term_meta($term->id, 'slug', $newSlug);
//update_post_meta($term->id, 'slug', $newSlug);
wp_update_term($term->id, 'experts_industries', array( 'slug' => $newSlug ));
error_log($term->slug);
}
}
add_action( 'wp_loaded', 'remove_stuff' );
BTW: I'm not worried about the wp_loaded action, I'm doing everything locally and then removing this code. Unless that's the problem...?