I finally managed to update the function. Here is the solution in case someone else also needs this functionality:
1. Follow sama55 instructions to create my-layer plugin
2. Paste the following code in qa-my-layer.php:
class qa_html_theme_layer extends qa_html_theme_base {
public function q_view_content($q_view) {
if(isset($q_view['raw']['postid'])) {
if($q_view['raw']['postid'] == '203') {
$content = isset($q_view['content']) ? $q_view['content'] : '';
$content_block = explode('<p>',$content);
if(!empty($content_block[2]))
{ $content_block[2] .= '<div align="center">
My awesome div here</div>';
}
$j = count($content_block);
for($i=1;$i<$j;$i++)
{ $content_block[$i] = '<p>'.$content_block[$i];
}
$content = implode('',$content_block);
$this->output($content);
}
else{
qa_html_theme_base::q_view_content($q_view);
}
}
}
}
3. Change the post id with your post id.