Notifications
Clear all

wpForo 1.x.x [Closed] Retrieve the thread's likes number

5 Posts
3 Users
1 Reactions
1,500 Views
Posts: 15
Topic starter
(@yahoyaho)
Eminent Member
Joined: 5 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
Posts: 15
Topic starter
(@yahoyaho)
Eminent Member
Joined: 5 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 🙂

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

Support Team
Posts: 10587

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

 

(@yahoyaho)
Joined: 5 years ago

Eminent 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 🙂

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

Support Team
Posts: 4772

@yahoyaho,

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