Notifications
Clear all

wpForo 1.x.x Retrieve the thread's likes number

5 Posts
3 Users
1 Likes
883 Views
yahoyaho
Posts: 15
Topic starter
(@yahoyaho)
Active Member
Joined: 3 years ago

Hi 😀

First of all I appreciate your supports.

I have a question.

I would like to show how many the first topic has "likes" on the threaded table (wpforo/wpf-themes/classic/layouts/4/topic-thread.php)

I would like to show the numbers besides the number of comments.

How can I retrieve the first topic's likes number?

I found the code "<?php wpforo_post_likers($post['postid']); ?>" but don't know how to get postid on the table.

Could you please give a tip?

Many many thanks.

Have a good day! 🙂

Sincerely,

Jen

 

4 Replies
yahoyaho
Posts: 15
Topic starter
(@yahoyaho)
Active Member
Joined: 3 years ago

I don't know whether it is the best practice or not,

Adding this line to fuction-template.php

$thread['likes_count'] = WPF()->post->get_post_likes_count($thread['first_postid']);

After that, $thread['likes_count'] works well.

Thank you 🙂

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

Support Team
Posts: 9278

@yahoyaho,

This is a bad practice, You should remove it.

Use this in the wpforo/wpf-themes/classic/layouts/4/topic-thread.php template file:

<?php echo WPF()->post->get_post_likes_count($thread['first_postid']); ?>

Note: all customization of template files should be done in update-safe way described in the documentation: https://wpforo.com/docs/root/forum-themes/theme-customization/

 

Reply
yahoyaho
(@yahoyaho)
Joined: 3 years ago

Active Member
Posts: 15

Wow @Robert

Thanks for your supports!! I appreciate it.

Thanks to you, I could edit that code in a better way.

I have one more question. Is it possible to use customized CSS files under theme folder like theme-cusomization?

Many thanks 🙂

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

Support Team
Posts: 4057

@yahoyaho,

Please follow this support topic: https://wpforo.com/community/how-to-and-troubleshooting-2/customizing-css-file/#post-37580

 

Reply
Share: