SQL only in custom Wordpress post for tag conversion

Asked

Viewed 100 times

1

Let’s say a site using Wordpress has half the posts of the default type, and the other half using a Custom Post Type "review" http://codex.wordpress.org/pt-br:Tipos_de_Posts_Personalizados.

But this type of post had no registered tags, so it shared those of the standard posts (post_tag).

Then the custom tag is assigned to custom posts, so it uses "review-tag". How can I via SQL convert the default tags only within these custom posts to the new type?

This command, for example, converts ALL tags:

UPDATE wp_term_taxonomy SET taxonomy='review-tag', parent=0 WHERE taxonomy='tag';

But I need to do this only with posts like review.

1 answer

1

Take a look at the link below to understand the relationship between the tables:

http://codex.wordpress.org/Database_Description

You need to make a Join of the wp_posts tables with wp_term_relationships and then with the wp_term_taxonomy table to be able to filter by post_type = "review" and know which taxonomies to change.

Anyway, I believe it will be simpler, and less risky, to make this change by wp-admin itself.

Browser other questions tagged

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