Cache WordPress Popular Posts queries
-
Hi!
I have a little problem with the plugin. It seems that the results it shows are not in cache at all. I mean, every time someone visits my website, a quite long query is executed. Since I’m receiving a lot of visits last months I’m having troubles with my server, which could not process all the queries when I have some simultaneous visits.
The query that is launched every time is long and a bit difficult to understand:
SELECT wp_posts.ID, wp_posts.post_title, ( SUM( wp_popularpostsdatacache.pageviews ) ) AS 'pageviews' FROM wp_posts RIGHT JOIN wp_popularpostsdatacache ON wp_posts.ID = wp_popularpostsdatacache.id WHERE wp_posts.post_status = 'publish' AND wp_posts.post_password = '' AND wp_popularpostsdatacache.day = CURDATE( ) AND wp_posts.post_type = 'post' AND wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships AS r JOIN wp_term_taxonomy AS x ON x.term_taxonomy_id = r.term_taxonomy_id JOIN wp_terms AS t ON t.term_id = x.term_id WHERE x.taxonomy = 'category' AND object_id IN ( SELECT object_id FROM wp_term_relationships AS r JOIN wp_term_taxonomy AS x ON x.term_taxonomy_id = r.term_taxonomy_id JOIN wp_terms AS t ON t.term_id = x.term_id WHERE x.taxonomy = 'category' AND t.term_id IN ( 4, 6, 11, 1070 ) ) ) GROUP BY wp_posts.ID ORDER BY pageviews DESC LIMIT 10
In my site, I’m showing three lists of most popuplar post with the following functions:
Daily:
<? wpp_get_mostpopular('order_by="views"&range="daily"&header=""&header_start=""&header_end=""&pages=0&stats_comments=0&cats_to_exclude="4,6,7,11,1070"&post_start="<li>"&post_end="</li>"&wpp_start="<ol>"&wpp_end="</ol>"&limit=10'); ?>
Weekly:
<?php wpp_get_mostpopular('order_by="views"&range="weekly"&header=""&header_start=""&header_end=""&pages=0&stats_comments=0&cats_to_exclude="4,6,7,11,1070"&post_start="<li>"&post_end="</li>"&wpp_start="<ol>"&wpp_end="</ol>"&limit=10'); ?>
Monthly:
<?php wpp_get_mostpopular('order_by="views"&range="monthly"&header=""&header_start=""&header_end=""&pages=0&stats_comments=0&cats_to_exclude="4,6,7,11,1070"&post_start="<li>"&post_end="</li>"&wpp_start="<ol>"&wpp_end="</ol>"&limit=10'); ?>
Can anyone give me any advice about this? How could I cache this query? I’m already using W3 Total Cache plugin for the the general queries and more things but it seems that is not working well with this query.
Any advice will be really appreciated. Thanks in advance and good work with this two awesome plugins! ??
https://www.ads-software.com/extend/plugins/wordpress-popular-posts/
- The topic ‘Cache WordPress Popular Posts queries’ is closed to new replies.