Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
  • Register
Welcome to the Q&A for Question2Answer.

If you have questions about the platform, click here to ask and please use English.

If you just want to try Q2A, please use the demo, which also grants admin access.

Apr 29: Q2A 1.5.2

Editing and reindexing the tags of many posts at once?

+1 vote

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".

asked Aug 16, 2011 in Q2A Core by DisgruntledGoat

1 Answer

0 votes

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.

answered Aug 17, 2011 by gidgreen
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?
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')