Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Question2Answer: Get excerpt of the question to display on the question list. Make sure your q2a function should get post id in array otherwise this code won't work.
$pid = $q_item['raw']['postid'];
$query = qa_db_query_sub("SELECT postid, content, format FROM ^posts WHERE postid = $pid");
$cont = qa_db_read_one_assoc($query);
$blockwordspreg = qa_get_block_words_preg();
$text=qa_viewer_text($cont['content'], $cont['format'], array('blockwordspreg' => $blockwordspreg));
$text=qa_shorten_string_line(qa_html($text), 200); //200 is the length
$this->output('<p class="your-class-for-text">',$text,'</p>'); //you can remove 'p' if you don't want
Copy link

zerg052689 commented Jul 26, 2018

and where need to add this code? some help ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment