2
Good morning,
I am currently working with a project for a news portal that is the grouping of 4 different companies, but one of these companies will cease to exist and all its posts will be transferred to another company within the portal.
To make the separation between companies within the administrator I am using the standard post type of Wordpress(post) and more 3 custom posts for the other houses. The company that will cease to exist is using the standard Wordpress post type.
The content migration (post published) between the default post type and the custom post I have already performed via direct query in the database and is ok.
In the meantime, content stays with old categories and I need to update with categories as well.
To illustrate:
Suppose I have the following categories in the company that will be extinguished:
- Company 1 (parent category)
- Politics (category daughter)
- Cities (category daughter)
- Sport (category daughter)
And the following categories in the custom post
- Company 2 (parent category)
- Politics (category daughter)
- Cities (category daughter)
- Sport (category daughter)
When I created a news post in the default Wordpress post I assign to the post the categories Company 1 -> Policy.
After the change I need to change the reference that before was Enterprise 1 -> Policy for Enterprise 2 -> Policy.
For the custom post I am using a specific custom Category due to the business rules of the project.
To try to understand how Wordpress works when I select a category for a post I was watching the mysql query log, but I could not take much advantage of this approach, I looked for plugins that could help me and the ones I found made a "merge" between categories. For reference the links of the plugins follow below:
This migration of categories is important because it is the categories that identify which company is the news.
The only way that I could see to do this update is via SQL query directly in the database, but the queries I executed did not take effect.
The following is a reference to two of the queries executed:
UPDATE wp_relationships SET term_taxonomy_id = 270 WHERE term_taxonomy_id = 380;
UPDATE wp_term_relationships SET term_taxonomy_id = (SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE term_id = 340) WHERE term_taxonomy_id = (SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE term_id = 112747);
The problem requires more marrow than I can offer right now... check if this helps: Unmark a category x of all wordpress posts
– brasofilo
I’ll take a look, thanks for the comment
– Lucas Bernieri Ramos
It may be that the solution is even via Mysql, but I recommend searching for native WP methods... there in [wordpress.se] has a lot of good material, just search for the name of table field or WP Function/hook that will find legal references
– brasofilo