Displaying Post Views in Archive Pages
-
This plugin is great and easy to use in single posts, but it is very slow in archive pages (tags, categories, search results, archive by date, etc.). I was trying to optimize it by creating a custom query that gets a list of posts and their views in one shot. However, dealing with transient data in
Options
table is quite difficult.Currently, the best solution I can think of is to get the list of post IDs to be displayed, then run a custom query similar to the following:
SELECT * FROM _DDV_options where option_value Like '%"post":{"ID":[first_post_id]%' or Like '%"post":{"ID":[second_post_id]%' … or Like '%"post":{"ID":[last_post_id]%';
After that, parse the JSON values in
option_value
field to get the views value which looks like (“views”:1234), and finally loop again to display these values in their proper locations in HTML (e.g. next to meta fields).I do not think this is the easiest nor the most efficient way to do it. Any suggestions?
Note: I posted further details in the below thread in www.remarpro.com Forums.
How to optimize Jetpack Page Visits Counter? | www.remarpro.com
- The topic ‘Displaying Post Views in Archive Pages’ is closed to new replies.