Sean H
Sean H

Reputation: 1066

Rename a category in WordPress

How do I programmatically rename a category in WordPress? I can't find any method for it in the Codex.

Obviously I'd like all posts in that category to be updated to be in the newly named category.

Thanks

Upvotes: 2

Views: 926

Answers (1)

Kedar Jangir
Kedar Jangir

Reputation: 525

I have done something like this before

There is a function in wordpress for it.

Example

 /* category name change*/
wp_update_term( 2, 'category', array(
    'name' => 'Repeated',
) );

Here i change the specific category name

There are three parameter:- 1. term id of category taxonomy 2. taxonomy name ( i.e. category ) 3. arguments ( here I changed the name only, you can change the slug and etc. )

Upvotes: 2

Related Questions