Closed rsmouk closed 2 years ago
Hi @rsmouk,
Yeah, I guess so. You need to define what makes a post "popular" though.
For example, you could add that hot
class to a post if it exceeds N views:
<li class="item <?php echo ( function_exists('wpp_get_views') && wpp_get_views( get_the_ID(), 'all', false) >= 1000 ) ? 'hot' : ''; ?>"> ... </li>
@cabrerahector Thank you for your response and your support for this special addition.
about the question: I do not want to limit the number of visits. I want to add a class to the trending article during the day, or the week .. regardless of the number of visits. I hope you understand me
Well, if you don't want to set a minimum amount of views to mark a post as "hot" then another thing you could do is get a list of the most popular posts from the last 24 hours (eg. via the \WordPressPopularPosts\Query class), then compare their IDs with the IDs from the posts from your archive list and mark the ones that match as "hot".
@cabrerahector I am a beginner in this field Can you give me the full code? With my respects.
I'm available for freelance work if you need help with this if you're interested.
I send you an email , please cheek
Is there a possibility to check if an article in the archive is popular? For example: When viewing the latest articles published on the site, I want to add a hot class to the popular article in the list