Support » Fixing WordPress » Delete tags with less than X posts

  • Hi there,
    I have a multiauthor blog that has become a TAG nightmare, and I want to delete every single tag that has less than 3 or 4 post on it, besides doing it trough the admin, Is there a way to do that trough MySQL? 🙂
    thanks in advance!

Viewing 15 replies - 1 through 15 (of 17 total)
  • While there *is* a way to do it with sql that really isn’t something that I would suggest doing.

    In the wp-admin -> posts -> tags page you can click on the word “posts” that is in the display area for all of the tags and it will sort all of the tags by how many posts they are in.

    This would be more preferred then and SQL statement IMO because you have the opportunity to checkmark just the ones you want to delete and bulk delete them.

    One of my rules of tags is that the word used as a tag must be inside the post as well and unique.

    Another is that description tags that are the same as the genre of the site are not needed. For example, if the website someone has is for webcomics, the tags: comic, webcomic, comics etc.. should *not* be used since it’s already relevant that the site itself is a webcomic.

    So instead of deleting all of those tags that are under 4 posts, you *should* be looking at all those tags that have a ton of posts associated to them. More then likely they are more irrelevant as tags then those ones that have only a few posts associated. To reiterate the less likelyhood of a tag being used in multiple posts = better.

    Excellent point of view 🙂

    To reiterate the less likelyhood of a tag being used in multiple posts = better.

    Not picking a fight but I don’t understand this logic. What good does that do? You get basically zero organization with that– no additional functionality at all that I can tell. That is, you aren’t grouping posts together in any way. You are just adding a value that really has no good reason to be. What good is a tag archive if every archive is a list composed of a single post? Tags should connect posts together in an kind of “related posts” way. If they aren’t doing that, and they aren’t if a tag applies only to a single post, I can’t figure out what they are doing or why you’d want to bother with them.

    @s_ha_dum, read the paragraph again, it was a reiteration of not using a commonality that could be distributed to most all posts.

    Yes, you were… and that is exactly what doesn’t make any sense to me, which was my point. I’ll read it again though.

    Ok. Read it again. Still doesn’t make sense.

    I get that you don’t want tags to distribute to most posts or even to a lot of post, if that is what you mean. That is as useless as having tags that only apply to one post.

    My question is about the logic of your position. What is the point of tags that apply to only a single post, as your “Services” and “Pricing” tags do on your website? I don’t understand that. I fail to see the benefit. Maybe you can explain it though. That is what I am asking for.

    Back to the original post though. I don’t know of a way to remove tags with low post counts, except with a direct DB query. It would probably be a complicated query at that, which makes it prone to error. There may be a plugin.

    I am dealing with a tag nightmare too, on three installs, so I feel for you. Our writers have created thousands of hyper-specific tags (some of which have no posts associated !?!?!). I’ve decided to make them clean it up using some more reasonable standards. Many of the tags can be combined in different ways to create something that is actually usable.

    The reason I only have a single post for ‘services and pricing’ as tags is because I don’t have any more posts yet on the subject, not cause there’s only 1 post, just that there are no more posts yet that have those references.

    I am not writing, stating that only have completely unique tags per post, I am stating that having tags that encompass the entire trope of your website is not necessary.

    In example, my nickname is Frumph, people already know that. If I tag all of my posts with my nickname that would be completely redundant. If I were to tag my posts with the name of the author who posted the post, again .. extra tags that are irrelevant. If I tagged my wordpress posts “WordPress” again, it’s already set in the category there is no need to set an additional one.

    Tagging of posts *should* in my opinion only encompass the main topics of discussion of the post itself and any relevant inclusions of necessary people in the post itself. Tagging has nothing to do with “grouping” like minded posts, that’s what categories are for. Tagging should be used for denoting the posts concept of what it is trying to say to the end user.

    If you take the scientific methodology of implementation of a phylum and class distinction of animal species you have a particular animal kingdom and under that you have your distinctions, the kingdom/phylum would be the categories and the distinctions would be the tag. In this reference you shouldn’t have cross kingdom tags because they are different elements except when the genre is itself a cross reference. Superhero and Movies for example would be a cross reference.

    Tags make the concept of the post, a reiteration of what is written in the post, those tags should be words used inside the post or a perspective of what the concept of the post is relational to. Tags should not be an all encompassing grouping mechanism that would coincide with an abundant of the same post concepts that basically is already understood by the genre of the site already.

    @frumph I got your logic, dont worry, in that context it will be good.

    @s_ha_dum in other contexts (ie: my author wrote used “S3” “S 3” “SIII” “Galaxy S3” ad infinitum :P) its a true nightmare, so for instance I have tags for numbers, quotes, users, and that doesnt help on this case.

    Problem is, since I have around 761 pages of tags and removing everything below 3 post/tag can leave less than 300 pages; i think its a great way to avoid useless content and pages (I even have tags witho no posts associated :S)

    I´ve tried to find a plugin but I couldnt, so i though a MySQL query might be good idea :S

    Thank you both 🙂

    You have a very different idea of what tags are than I do. My idea is more like this:

    Tags provide a useful way to group related posts together and to quickly tell readers what a post is about. Tags also make it easier for people to find your content. Tags are similar to, but more specific than, categories.


    I get half or more of your point, and agree. I don’t understand why you think tags have nothing to do with grouping. I don’t understand why you think tags are a ‘distinction’ under a particular category as your analogy implies. And I don’t understand how your use of tags is useful. But, as I said before, I am not interested in arguing. Thanks for explaining your position.

    @s_ha_dum in other contexts (ie: my author wrote used “S3” “S 3” “SIII” “Galaxy S3” ad infinitum :P) its a true nightmare, so for instance I have tags for numbers, quotes, users, and that doesnt help on this case.

    You and me both… I’ve got all kinds of mess. I’ve got “07” as a tag. I’ve got “5”, as well as “1st bank”, “1st Bank Center”, and “1stbank”. I’ve got really weird ten word tags… I try hard not to think about it much. I’ve got nearly 6000 of these on one site alone. sigh…

    Given the complicated taxonomy structure used by WordPress these days (three tables at least) I strongly advise a great deal of caution with direct database queries. If I were to do this, I would create a temporary function in my functions.php file. Pull a list of tags and loop through them, checking the post count each time and deleting the ones with fewer that ‘n’ associated posts. If you had some naming patterns that you absolutely wanted to remove– single digit numbers or something– you could remove those in the same loop as well. By doing it this way you can use WordPress functions to edit things, which should be much less error prone.

    @s_ha_dum … nice, running it once every couple of months would stop this kind of mess; if I get a good solution (or query :P) i´ll share it here 🙂

    The only drawback is that you can’t really analyze tag relevance. For example, if you had ‘tag-a’ with 3 posts and ‘tag-b’ with 2 posts, and you are deleting everything with 4 or fewer posts then both tags get deleted even if both tags are conceptually the same and could reasonably be combined giving you a tag over your minimum. Does that make sense? There is really no way to automate that kind of thought process though.

    @s_ha_dum the ideal”process” would be to analize it not only by relevance but also typos (ie: mtematica instead of matemática) but… more than 700 pages would take me years 😉

    …analize it not only by relevance but also typos…

    Not impossible but that is a pretty complicated function no matter how you do it. There is a way to do this with a dictionary list that isn’t too horrible. It is also not 100% accurate, if you are interested.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Delete tags with less than X posts’ is closed to new replies.