I don’t profess to be a complete expert on WordPress and its finer workings.
Whenever I want to do something like a bulk modification or something like that, I tend to search around for some kind of plugin or some other solution on the Internet. I am rarely disappointed.
I have been doing some modifications over on Head Rambles where I have shifted the links (Blogroll) onto a separate page. I wanted to go a little further with this and to do this, I needed to place the links into the database rather than have them hard coded on a page.
I am a great fan pf PHPMyAdmin, so writing up an SQL textfile to insert a batch of links into the Links Table was relatively simple. The Links Table had some legacy stuff in there so the result was a refreshed table with 147 entries. So far so good.
I wanted to set all my Links to a particular category, and this is where I ran into a problem. The last thing I wanted to do was to have to manually edit 147 entries and it would have been extremely slow and tedious. I searched high an low and found quite a few others trying to do the same thing, but no solutions. I had discovered the numerical identity of the category (it was 2) and tried a bulk change of the field ‘link_category’ to 2. This didn’t work, for some reason.
On delving a little further, I found that in fact the relationship between links and categories is held in the table Term_Relationships. As an experiment, I went back to my text editor and built up a series of inserts for this table –
INSERT INTO `term_relationships` (`object_id`, `term_taxonomy_id`, `term_order`) VALUES
(X, 2, 0),
(X, 2, 0),
(X, 2, 0);
where X is the ID of the link.
On running this file, I got several errors indicating duplicate fields. These represented the legacy entries, which was fair enough. I just deleted the relevant entries from the text file.
Ultimately, my batch fix worked, and all the links are now entered under their correct categories.
I strikes me though that this would be a fine opportunity for someone to develop a plugin that does batch jobs on Links?