Content migration between different post types in Wordpress

Asked

Viewed 296 times

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:

Batch-Move Posts wp plugin

Term Management Tools

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

  • I’ll take a look, thanks for the comment

  • 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

1 answer

0

In a survey I found your question. Well, come on... Update this post... (laughs). News portal is with me. I’ve been there...

Well... What is most practical in this case... (In my opinion) It’s changing the category names... And so after the change create a new... With a totally different name to have a reference, after all the names are similar and we ended up confusing. With the different category (Ex: XPO), go straight to POSTS. Thus changing all the contents of the category (Policy 1) that belongs to Company 1. In POSTS send with ease to the XPO category, which has just created.

After all posts in the new category. Change the name of the Category and do not forget the SLUG of the category -> (URL)

As I see are many posts...

And you went down a good path that is SQL, but as you have similar names can confuse. And the system itself might misinterpret, but you’re orienting yourself by taxonomy ID.

In this case the problem is the canonical URL, which should possibly look like the old one. Be careful. So I emphasize. In the creation of the New CATEGORY (to which you will import), a different name. Initially... When everything is already there... Just change...

Good, about SEO and links...

I recommend writing down the previous categories references. And use the Plugin (Redirection), it is very good. In this case cited would just create a single rule. And not all posts.

I particularly don’t like using SQL/Mysql. Only in the latter case.

I hope I helped. If you have any questions, please comment...

Hug!

  • @Lucas Bernieri Ramos What was your solution. Your case study was different?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.