Notifications
Clear all

Add snippet of first post into forum list

17 Posts
3 Users
5 Likes
1,366 Views
Sofy
Posts: 4057
 Sofy
Admin
(@sofy)
Support Team
Joined: 5 years ago

Hi @anonymous3542,

I'll ask developers and let you know asap. 

Reply
Anonymous3542
Posts: 393
Topic starter
(@anonymous3542)
Reputable Member
Joined: 5 years ago

@sofy thanks very much.

Reply
2 Replies
Sofy
 Sofy
Admin
(@sofy)
Joined: 5 years ago

Support Team
Posts: 4057

@anonymous3542,

As far as I understand you'd like to mix the wpForo first Extended layout with the Threaded layouts, am I right? 

As you may see the wpForo Threaded layout includes only the titles. 

So what content you'll need to add here? Would you like to add some content from the first post or something else? 

Reply
Anonymous3542
(@anonymous3542)
Joined: 5 years ago

Reputable Member
Posts: 393

@sofy that's correct. I'm just looking for the body of the first post in each topic to be displayed underneath

Reply
Sofy
Posts: 4057
 Sofy
Admin
(@sofy)
Support Team
Joined: 5 years ago

Hi @anonymous3542,

I've asked deveolpers and the best way to do it I'll describe below. 

You should customize the forum-thread.php file in the wp-content/plugins/wpforo/wpf-themes/classic/layouts/4/ folder.

Add the following code in the file.  The code will show the body of the first post. I've attached the image below, please check it. On the screenshot, you'll see the row you should add the code.

<div class="custom-wpf-thread-first-post-body">
<?php
$topic = wpforo_topic($topicid);
$first_post_body = wpforo_post($topic['first_postid'], 'body');
wpforo_text($first_post_body, 250);
?>
</div>

As I've mentioned the code will just show the body of the first post. You'll need to add some CSS code, to display as it should be.

Reply
3 Replies
Anonymous3542
(@anonymous3542)
Joined: 5 years ago

Reputable Member
Posts: 393

@sofy thanks very much for this. I've revamped this slightly to give it a more "native" feel - personally, I think this should be in the core, but that's just me

 <div class="custom-wpf-thread-first-post-body">
<?php

$topic = wpforo_topic($topicid);
$first_post_body = wpforo_post($topic['first_postid'], 'body');
// strip tags to avoid breaking any html
$string = strip_tags($first_post_body);
if (strlen($string) > 500) {

// truncate string
$stringCut = substr($string, 0, 500);
$endPoint = strrpos($stringCut, ' ');

//if the string doesn't contain any space then it will cut without word basis.
$string = $endPoint? substr($stringCut, 0, $endPoint) : substr($stringCut, 0);
$theurl = esc_url($thread['url']);
$string .= '...... <a href="' . $theurl . '"><span class="green"><b>Read More</b></span></a>';
}
echo "<div class='excerpt'>" . $string . "</div>";
?>
</div>

The CSS is simple enough - the excerpt doesn't show if in mobile view for obvious reasons

 

Reply
Sofy
 Sofy
Admin
(@sofy)
Joined: 5 years ago

Support Team
Posts: 4057

Hi @anonymous3542,

I think this should be in the core, but that's just me

We'll discuss with our team to add this in plugin core. 

Reply
Robert
Admin
(@robert)
Joined: 6 years ago

Support Team
Posts: 9334

@anonymous3542,

I'm sorry but this is out of the threaded layout idea. You're asking change the threaded layout to extended layout. The result will be close to the extended layout. So this can only be done individually, I'm sorry but we'll not add it in core.

Reply
Page 2 / 2
Share: