Forums

Writing a Plugin that Deletes Tags (3 posts)

  1. Tom Belknap
    Member
    Posted 2 years ago #

    I'm sort of surprised that, as far as I can tell, WordPress does not seem to have a function that will gracefully delete tags. I'm writing a plugin that is specifically tailored to finding orphaned or irrelevant tags in your blog and deletes them, but I'm not seeing this function which I assumed would naturally be there.

    So, here's the question: is there a function that I'm missing that will delete tags? And if not, is simply deleting the term from the database acceptable? Seems to me that you'd want to delete the relationship between the tag and the posts it was assigned to, for tidiness' sake, but I haven't seen any negatives to just pulling out the term.

    Thanks for your help!

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

  2. apljdi
    Member
    Posted 2 years ago #

    The Tag Management Page-- Posts->Tags-- seems pretty graceful to me, but it would be nice if you could order by 'Posts'. That would give you your 'orphaned' tags. The 'get_terms()' function support an 'orderby' arg but I'm not sure if you can pass one to it without hacking 'tag_rows()' which looks to be missing a kinda useful parameter. Finding 'irrelevant' tags might be a trick.

    But to delete tags, I think the function you are looking for is 'wp_delete_term()'. Look in wp-includes/taxonomy.php.

  3. MichaelH
    Volunteer
    Posted 2 years ago #

    Must be a consensus here as Austin suggested the same thing on the wp-hackers list:

    http://comox.textdrive.com/pipermail/wp-hackers/2009-February/024972.html

Topic Closed

This topic has been closed to new replies.

About this Topic