Wednesday, February 9, 2022

[FIXED] Upload Text File Containing Long List of Tags to WordPress

Issue

I have a text file with about 6700 tags that I would like to add to my Word Press site. Of course, it is not efficient to do this manually. Is it possible to automate the insertion of these tags?

I tried a few plugins like Smart Tag Insert, but these are ineffective and have low review scores. Additionally, I see that tags in my MyPHPAdmin panel are stored in the table wp_terms. I wanted to write an SQL script that does what I need. However, the table also stores a series of other values (like menu names). There is no way to identify rows in this table as tags and not something else (like the name of a menu). So, I am also confused about that too.

Thank you for your time and help!


Solution

You should loop through all the tags in the file and then use the wp_insert_term function to insert the tags into the database.

Documentation : https://developer.wordpress.org/reference/functions/wp_insert_term/

So the first argument is the tag term and the second one is post_tag.

Exemple:

wp_insert_term(
    'tag_name',   // the term 
    'post_tag', // the taxonomy
);


Answered By - Thomas LIBERATO

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.