Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
in Q2A Core by
How can I set 20 random questions as homepage ?

1 Answer

+1 vote
selected by
Best answer

I  don't see an option in the config, but you can do this by changing this code:

File: qa-include/db/selects.php
Function qa_db_qs_selectspec

@@ -359,5 +359,5 @@
                case 'created':
                case 'hotness':
-                       $sortsql = 'ORDER BY ^posts.' . $sort . ' DESC';
+                       $sortsql = 'ORDER BY RAND()';

Will it affect on speed of website?
I know ORDER BY RAND() works by generating a random number for each row and then sorts by that.  Generating that number is extra work.  Sorting by this number or by creation date would be same.  I would say ORDER BY RAND() will have an overhead.  I haven't measured the performance, so I don't know the overhead.  I tried it on my site (just a few hundred questions) and reloaded the page and didn't notice any visible delay in loading the page.
@Zeeshan I tried this code but it didn't work for me