Notifications
Clear all

wpForo 1.x.x [Closed] Add "NEW" to fresh content, and an excerpt in threaded posts

8 Posts
2 Users
1 Reactions
2,510 Views
Posts: 393
Topic starter
(@anonymous3542)
Honorable Member
Joined: 7 years ago

I know someone on here asked about adding a "Fresh" or "New" icon when a new post is added - so I've done exactly that as I think it enhances the user experience. Additionally, I've added an excerpt with "Read More" under the topic thread title.

Have a look here - https://inocul8r.net and let me know if you'd like the code changes (it requires templates - please don't modify the core as your changes will over overwritten on the next update)

 

7 Replies
Posts: 533
(@central4allgmail-com)
Prominent Member
Joined: 6 years ago

This looks like a great feature if you can share the code

Posts: 533
(@central4allgmail-com)
Prominent Member
Joined: 6 years ago
@anonymous3542 is there a problem with the code to share with us?
Posts: 393
Topic starter
(@anonymous3542)
Honorable Member
Joined: 7 years ago

@central4allgmail-com sorry - been busy. Here's the code, plus where it goes

Note, that this assumes you have the threaded layout, as that's what my entire forum is structured with. You should also have custom templates ready, otherwise, your changes will be overwritten on each update. Based on this, I'm assuming you have templates already located inside a "wpforo" directory in your theme's folder

Take a backup of all files before you modify them 🙂

1. Edit file /wpforo/layouts/4/forum-thread.php. Place the below code around line 7

$range = date('Y-m-d',strtotime("-3 days")); 

2. Find the DIV block <div class="wpf-thread-box wpf-thread-date"> which should be around line 34, and replace with the below

 <div class="wpf-thread-box wpf-thread-date">
<?php if($thread['created'] > $range) {$newpost = "<br><div class='newpost'>NEW</div>";} else {$newpost = "";} ?>
<?php echo $thread['last_post_date'] . $newpost ?>
</div>

3. Save the file

4. Save the below block of custom CSS either inside the wpForo settings, or within your own theme

.newpost {
background: #28b62c !important;
padding: 3px !important;
padding-left: 10px !important;
padding-right: 10px !important;
color: #ffffff !important;
font-size: 0.6rem !important;
font-weight: 700 !important;
margin-left: 10px !important;
border-radius: 0.2rem !important;
margin-top: 5px !important;
width: 50%;
display: inline-block;
}

Note that you'll need to tailor this to suit - don't forget that my templates are heavily customised. I'm also having to use !important to override some classes. This probably won't be necessary in your theme.

5. Modify /wpforo/layouts/4/topic-thread.php in the same manner. Place the below code around line 7 of topic-thread.php

$range = date('Y-m-d',strtotime("-3 days")); 

6. Find the DIV block <div class="wpf-thread-box wpf-thread-date"> which should be around line 30, and replace with the below

 <div class="wpf-thread-box wpf-thread-date">
<?php if($thread['created'] > $range) {$newpost = "<br><div class='newpost'>NEW</div>";} else {$newpost = "";} ?>
<?php echo $thread['last_post_date'] . $newpost ?>
</div>

7. Save the file

8. Clear caches, and review. Hopefully, all went well, and things look like they should. 

 

 

 

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

Also, if you're looking for the "excerpt in threaded posts", this can be found here

Page 1 / 2