Notifications
Clear all

[Closed] Add snippet of first post into forum list

17 Posts
3 Users
5 Reactions
2,649 Views
Sofy
Posts: 4900
 Sofy
Admin
(@sofy)
Support Team
Joined: 7 years ago

Hi @anonymous3542,

I'll ask developers and let you know asap. 

Posts: 393
Topic starter
(@anonymous3542)
Honorable Member
Joined: 7 years ago

@sofy thanks very much.

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

Support Team
Posts: 4900

@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? 

(@anonymous3542)
Joined: 7 years ago

Honorable 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

Sofy
Posts: 4900
 Sofy
Admin
(@sofy)
Support Team
Joined: 7 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.

3 Replies
(@anonymous3542)
Joined: 7 years ago

Honorable 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

 

Sofy
 Sofy
Admin
(@sofy)
Joined: 7 years ago

Support Team
Posts: 4900

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. 

Robert
Admin
(@robert)
Joined: 9 years ago

Support Team
Posts: 10591

@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.

Page 2 / 2