this plugin show only one question but I needed multiple questions (about 6) so I have changed the code like this
<?php
class q2a_random_question {
function allow_template($template) {
$allow = false;
switch ($template) {
case 'account':
case'activity':
case'admin':
case'ask' :
case'categories' :
case'custom' :
case'favorites':
case'feedback' :
case'hot' :
case'ip' :
case'login':
case'message':
case'qa' :
case'question':
case'questions':
case'register' :
case'search' :
case'tag' :
case'tags' :
case'unanswered':
case'updates' :
case'user' :
case'users' :
$allow = true;
break;
}
return $allow;
}
function allow_region($region) {
return true;
}
function output_widget() {
$random_question = qa_db_read_one_assoc(
qa_db_query_sub('SELECT * FROM ^posts WHERE type=$
ORDER BY rand()
LIMIT 1',
'Q'),
true );
echo "<h2 style='text-align: left;'>Can you answer this questions ?</h2>";
//replace yourwebsite with your website
echo "<h4 style='text-align: left;'><a href='https://electronics2electrical.com/" . $random_question['postid'] . "'>" . $random_question['title'] . "</a></h4>";
$random_question = qa_db_read_one_assoc(
qa_db_query_sub('SELECT * FROM ^posts WHERE type=$
ORDER BY rand()
LIMIT 1',
'Q'),
true );
echo "<h4 style='text-align: left;'><a href='https://electronics2electrical.com/" . $random_question['postid'] . "'>" . $random_question['title'] . "</a></h4>";
$random_question = qa_db_read_one_assoc(
qa_db_query_sub('SELECT * FROM ^posts WHERE type=$
ORDER BY rand()
LIMIT 1',
'Q'),
true );
echo "<h4 style='text-align: left;'><a href='https://electronics2electrical.com/" . $random_question['postid'] . "'>" . $random_question['title'] . "</a></h4>";
$random_question = qa_db_read_one_assoc(
qa_db_query_sub('SELECT * FROM ^posts WHERE type=$
ORDER BY rand()
LIMIT 1',
'Q'),
true );
echo "<h4 style='text-align: left;'><a href='https://electronics2electrical.com/" . $random_question['postid'] . "'>" . $random_question['title'] . "</a></h4>";
$random_question = qa_db_read_one_assoc(
qa_db_query_sub('SELECT * FROM ^posts WHERE type=$
ORDER BY rand()
LIMIT 1',
'Q'),
true );
echo "<h4 style='text-align: left;'><a href='https://electronics2electrical.com/" . $random_question['postid'] . "'>" . $random_question['title'] . "</a></h4>";
$random_question = qa_db_read_one_assoc(
qa_db_query_sub('SELECT * FROM ^posts WHERE type=$
ORDER BY rand()
LIMIT 1',
'Q'),
true );
echo "<h4 style='text-align: left;'><a href='https://electronics2electrical.com/" . $random_question['postid'] . "'>" . $random_question['title'] . "</a></h4>";
}
}
But I think by doing this speed of my site became slightly slow..