• I’ve got a WordPress website that I’ve been running an auto tagger on for a while now, which has cause the database to grow to simply be too large and I need a little help cleaning it out.

    What I’d like to do is first, reset the _term_taxonomy table to count most tags as having 0 counts.

    UPDATE wp_term_taxonomy SET count = 0 WHERE count < 20;

    Next (and here’s where I’m hoping there’s a better suggestion … I need to purge all contents of both the wp_term_relationships and wp_term_relationships table where the wp_term_taxonomy count value is 0.

    I know I can do this by looping but this’ll cause serious server load issues, so is there a quick piece of SQL that anybody can recommend?

    [moderated–bump removed. Please refrain from bumping as per Forum Rules]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Nagmay

    (@gabrielmcgovern)

    I had the same problem and ended up with almost 40,000 tags. Here’s what I did:

    1) Open wp_admin/template.php

    2) Find line 721:

    $args = array(‘offset’ => $start, ‘number’ => $pagesize, ‘hide_empty’ => 0);

    3) Temporarily change to:

    $args = array(‘offset’ => $start, ‘number’ => $pagesize, ‘hide_empty’ => 0, ‘hide_empty’ => 0);

    This causes your post tag list (in the admin area) to display by ‘post count’ rather then ‘tag name’.

    You can then click ‘screen options’ to display 999 and begin to safely delete the low count tags.

    Hey Gabriel, thanks for the help, but I think your path should be:
    wp_admin/includes/template.php

    Not saying you’re wrong, just saying that’s where I found mine. 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘SQL code to bulk remove tag references’ is closed to new replies.