PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 9, 2022

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

 February 09, 2022     mysql, phpmyadmin, wordpress     No comments   

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
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

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

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing