AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Notifications
Clear all

[Closed] Retrieve the thread's likes number

5 Posts
3 Users
1 Reactions
2,168 Views
Posts: 15
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@yahoyaho)
Eminent Member
Joined: 6 years ago
[#12436]

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
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@yahoyaho)
Eminent Member
Joined: 6 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: 3 months ago

Support Team
Posts: 10762
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@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: 6 years ago

Eminent Member
Posts: 15
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

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: 8 years ago

Support Team
Posts: 5778
Robert
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@yahoyaho,

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

 


Share: