Info
- 3 posts
- 2 voices
- Started 2 years ago by blah
- Latest reply from blah
- This topic is resolved
show a snippet of the post under the topic title?
-
- Posted 2 years ago #
Is there a way to show a snippet of the post (limit 200 characters) under the topic title on the front page? I tried putting in "<?php post_text(); ?>" but nothing showed up. Any ideas?
-
- Posted 2 years ago #
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. -
- Posted 2 years ago #
Thank you that worked!
-
You must log in to post.