Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
282 views
in Q2A Core by

What is the best way to edit/delete many tags at once, within a Q2A plugin (in the admin section, not on an event or page load)?

I found some code in qa-page-tag.php that grabs all the questions with that tag. Do I need to modify each question with qa_post_set_content (which also does the content reindexing)? Or should I run a more direct SQL query and reindex afterward? Are there functions to just reindex a post's tags, not the whole content?

I don't expect this specific function to be used for more than 100 questions at a time, and if it did, it would basically be a "one-time thing".

1 Answer

0 votes
by

Considering the number of posts we're talking about, I think it makes most sense just to use qa_post_set_content(...) - that would be most future-proof.

by
OK thanks. Yet another question: the code from qa-page-tag.php only returns one page's worth of tags by default:

list($questions, $qcount)=qa_db_select_with_pending(
    qa_db_tag_recent_qs_selectspec(null, $oldtag, 0),
    qa_db_tag_count_qs_selectspec($oldtag)
);

I used "1000" as the $count parameter - i.e. (null, $oldtag, 0, false 1000) - as an interim hack but is there a way to actually get all the posts with a particular tag?
by
You need to specify some limit, but feel free to make it as high as you want. To be absolutely safe, you can pass in the number of questions from qa_opt('cache_qcount')
...