Skip to content

Instantly share code, notes, and snippets.

@q2amarket
Last active July 26, 2018 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save q2amarket/5816586 to your computer and use it in GitHub Desktop.
Save q2amarket/5816586 to your computer and use it in GitHub Desktop.
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.
<?php
$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
?>
@zerg052689
Copy link

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