Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
in Q2A Core by
Q2A version: 1.8

1 Answer

+2 votes
edited by

You'll have to hack the core.

1. Edit file db/selects.php

2. Change this part of the code in function qa_db_qs_selectspec:

$selectspec=qa_db_posts_basic_selectspec($voteuserid, $full);

$selectspec['source'].=" JOIN (SELECT postid FROM ^posts WHERE ".

into this

$selectspec = qa_db_posts_basic_selectspec($voteuserid, $full);

$hiddenCategoryIds = array(1, 2);
$hideInPages = array('', 'activity', 'questions');
if (in_array(qa_request(), $hideInPages) && !empty($hiddenCategoryIds)) {
    $sql = '(^posts.categoryid NOT IN (' . implode(',', $hiddenCategoryIds) . ') OR ^posts.categoryid IS NULL) AND ';
} else {
    $sql = '';
$selectspec['source'] .= " JOIN (SELECT postid FROM ^posts WHERE " .

You can get the category IDs from the admin panel in the categories section. Navigate to the category you want to hide and then check the URL. It should look like this:


So 7 is the category ID. Make sure you replace the content of the array with that ID:

$hiddenCategoryIds = array(7);

The $hideInPages array controls in which pages you want to hide them. If you don't want t see them in any additional page, then uncomment (remove the // from the echo qa_request();) and navigate to that page. You will most likely text in the top left corner of the page. Just add that text to the $hideInPages array. Then comment the uncommented line again.

Note about the /activity page: 

You will see the core has also these functions:


You'll have to perform similar edits to those functions in order to filter out all the questions (asked, answered, commented and edited). This answer just tackles the "asked" ones but fixing the rest should be trivial based on how the "asked" ones are fixed.

This is very very dirty and I wouldn't advise to hack the core that much... but it should get the work done.

I see now. The issue was I told to delete up to (including) the line with the: qa_db_categoryslugs_sql_args. That was a copy/paste issue and should have not been included to be replaced. So the addition should work, just don't remove that last line (I've updated the answer anyway).

Also see the note about the /activity page.

Finally, remember to add each of the pages you want these "exceptions" to be run (e.g.: if you want to hide questions under a given category then you have to add the output of the qa_request() in the $hideInPages array).
Hello Friend!

The code above asks the questions asked in a category to disappear from the homepage, but when the question is answered it appears again on the homepage. How do I resolve so that when the question is answered or commented, it does not appear on the homepage?

Sorry, I'm using a translator.
Please, re-read the answer. That was already part of the answer
Thanks a lot for the help!

I just can not understand exactly what I have to edit in the functions:

qa_db_recent_a_qs_selectspec ()
qa_db_recent_c_qs_selectspec ()
qa_db_recent_edit_qs_selectspec ()