When i edit a single post slug the old url redirects to the new one automatically.

I need to do this in bulk.

There is a text that appears on thousands of permalinks and i want to remove it from them all and keep wp native redirect, because this text appears in random places i cannot make an htaccess rule for all posts.

So for example:


Should become:


If someone access the old url redirect to the new one.

  • You should check first to make sure the new URLs will not create any duplicate slugs. Having /cpt1/hello-world/ and /cpt2/hello-world/ should work because they are different post types and so they have different overall URLs, but if you wind up with two /cpt1/hello-world/ posts then only one will be accessible.
    – WebElaine
    Nov 20 '19 at 14:22
  • I see. They are very different except for these unwanted words. I found a workaround i will post later on!!! Nov 20 '19 at 14:43

This is what worked for me:

 function remove_false_words($slug) {
  if (!is_admin()) return $slug;
  $keys_false = array('unwanted','word');
  $slug = explode ('-', $slug);
  $slug = array_diff($slug,$keys_false);
  return implode ('-', $slug);
add_filter ('sanitize_title', 'remove_false_words');

Then you can use wordpress dashboard to select all posts, bulk edit, Update. And the words will be removed from slugs with native redirect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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