Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
706 views
in Q2A Core by
What query do I need to use to get the count of questions related to a tag?

I added some tags to the sidebar, but I'd like to add just to the right the amount of questions that use that tag as well.
by
edited by
With newer versions of q2a, this is implemented in tag list. Check http://www.question2answer.org/qa/tags

You can use Noah's code below for a selfcreated widget.

1 Answer

+1 vote
by
Something like this:

$count = qa_db_read_one_value(
    qa_db_query_sub(
        'SELECT COUNT(postid) FROM ^posttags WHERE wordid=#',
        $tagid
    ),true
);
by
Noah, I guess this is within a post, isn't it? I actually need to get the values globally since they'll be placed in the sidebar, just aside thir corresponding tags. Any guess?
by
No, that's anywhere... all you need is a word id for each tag; if your widget is showing tags, you must have the word id for each tag, no?  Just pass it in as $tagid, then echo the output, $count.
...