Forums

[phpMyAdmin] Manually Deleted Tags from WP_Terms Table (5 posts)

  1. WP User
    Member
    Posted 1 year ago #

    Hi friends

    I have deleted some non-required tags directly from "wp_terms" table using phpMyAdmin.

    Now I think their references are still there in "wp_terms_relationships" and "wp_terms_taxonomy" tables.

    Is it true? If yes, how can I delete their references from other tables so that all 3 tables remain synchronized.

    btw following are the record size of 3 tables:

    wp_terms - 2154
    wp_terms_relationships - 39123
    wp_terms_taxonomy - 2587

    And "wp_posts" table contains 1326 records.

    Thanks in advance.

  2. vtxyzzy
    Member
    Posted 1 year ago #

    BACK UP YOUR DATABASE FIRST!!

    Use these two SELECT queries to see what will be deleted:

    SELECT *
    FROM wp_term_taxonomy
    WHERE term_id NOT IN (SELECT term_id FROM wp_terms)
    SELECT *
    FROM wp_term_relationships
    WHERE term_taxonomy_id NOT IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)

    Then, change 'SELECT *' to 'DELETE' to actually delete the rows.

  3. WP User
    Member
    Posted 1 year ago #

    ^^ Thanks a lot mate. It worked and now I have:

    wp_terms - 2156
    wp_terms_relationships - 33851
    wp_terms_taxonomy - 2075

    ==================

    Actually I ran a query to delete unused tags from wp_terms table which deleted 90-90 records from "wp_terms_taxonomy" and "wp_terms" tables.

    I had a backup of "wp_terms" table which I restored but I didnt have any backup of "wp_terms_taxonomy" table. Can you also post a query which will re-create those deleted records in "wp_terms_taxonomy" table which are present in "wp_terms" table.

    Thanks again for your help.

  4. vtxyzzy
    Member
    Posted 1 year ago #

    No way that I know of to match up the wp_term_relationships records and wp_terms records to recreate the wp_term_taxonomy records that link them.

  5. WP User
    Member
    Posted 1 year ago #

    ^^ Thats sad but really thanks for your help. If you come to know any way, please let me know. Thanks again.

Topic Closed

This topic has been closed to new replies.

About this Topic