{"id":18989911,"date":"2026-08-10T22:51:07","date_gmt":"2026-08-10T22:51:07","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/optimized-way-to-retrieve-most-liked-posts-by-category-and-time-period\/"},"modified":"2026-08-10T22:51:07","modified_gmt":"2026-08-10T22:51:07","slug":"optimized-way-to-retrieve-most-liked-posts-by-category-and-time-period","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/optimized-way-to-retrieve-most-liked-posts-by-category-and-time-period\/","title":{"rendered":"Optimized way to retrieve most-liked posts by category and time period"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hello,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I would like to implement a feature on my website using WP ULike.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I want to be able to retrieve the most-liked posts, grouped by category, and identify the most-liked posts on the site based on the number of likes within different time periods, such as:<\/p>\n\n\n\n<ul>\n<li>Weekly<\/li>\n\n\n\n<li>Monthly<\/li>\n\n\n\n<li>Quarterly (3 months)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For example, I would like to retrieve the top 10 most-liked posts in each category during the last 7 days, last 30 days, or last 3 months.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">My main concern is database performance. Since my website has a large amount of content and likes, I want to implement this in the most optimized way possible with the lowest possible database load.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What approach would you recommend for this?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Specifically, would you recommend querying the WP ULike tables directly, using an existing WP ULike feature\/API, creating a custom database query, or maintaining some kind of pre-calculated\/aggregated data?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I would also appreciate your recommendation for the most efficient database structure or indexing strategy for this use case, especially if the rankings need to be generated regularly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What would be the best and most optimized solution to achieve this while minimizing database queries and server load?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"template":"","class_list":["post-18989911","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18989911","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18989911\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=18989911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}