• Resolved hsatterwhite

    (@hsatterwhite)


    Is there a mySQL query that can be ran to change all of the category’s parent’s to a specific one and also exclude a category from being modified?

Viewing 4 replies - 1 through 4 (of 4 total)
  • See if this thread helps.

    Thread Starter hsatterwhite

    (@hsatterwhite)

    Indeed that will help once I add in an exclude parameter! I’ll post my query here when I’m done. Thank you gain vtxyzzy!

    Thread Starter hsatterwhite

    (@hsatterwhite)

    @vtxyzzy Thanks for the link above. I used that and then figured out how to add some logic to only target categories in the taxonomy and how to exclude specific categories from being modified. Excluding a category from being modified prevents a category from becoming it’s own parent. It will still execute correctly and WordPress will load, but you will not get a list of categories, because it’s illogical.

    UPDATE wp_term_taxonomy
    SET parent = 1115
    WHERE taxonomy='category' AND term_id != 1115

    In the example above I’ve used 1115 as my category I want to exclude from the statement, which can be modified to target any category ID as well as multiple categories.

    I hope this helps others as well.

    Thanks for the feedback. Now, please use the dropdown at top right to mark this topic ‘Reaolved’.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘mySQL to change parent categories’ is closed to new replies.