I have several categories in which I need to update/assign the parent category so that the default category (uncategorized) becomes the parent.
Its very easy to do this via the category manager, however, I need to do this via script.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The original source code for wp_update_cagetory() is:
So this seems self-explanatory:
Repeat the above for all categories you need updated.
UPDATE:
Pertaining to the problem of category ID retrieval – it seems that category_exists() function should do the job:
So this should work, but I didn’t test it: