Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: show a snippet of the post under the topic title?


Gautam
Member

@gautam2011

Create a functions.php file in your theme folder, and write this in it:

<?php
function get_post_teaser($chars = 200){
global $bbdb;
$topic_id_ft = get_topic_id(); //topic id for getting text of first post of the topic
$first_post = (int) $bbdb->get_var("SELECT post_id FROM $bbdb->posts WHERE topic_id = $topic_id_ft ORDER BY post_id ASC LIMIT 1");
$content = substr(strip_tags(strip_shortcodes(get_post_text($first_post))),0, $chars); //gets the first 200 chars of the post
return $content;
}
?>

Then at the front page, put this where you need to display the post text (it should be inside the loop):

<?php echo get_post_teaser(200); ?>

You can change that 200 to anything, any number of letters you want. Default is 200.

I think, this should work.

Skip to toolbar