Closed Beee4life closed 6 years ago
Storing data in a separate db table is intentional - for performance and optimization reasons - and will not be changed.
Generally you are right - storing data in custom table usually requires writing wpdb queries. But not in this case as we have extended native WP_Query class. If you set orderby parameter to "post_views" you can perform any WP_Query, including taxonomy and meta queries and get the total views in result.
Just check this file for details: https://github.com/dfactoryplugins/post-views-counter/blob/master/includes/query.php
Thanks for the reply. While I understand what you say, I don't really agree. Imo all post meta should be stored in _postmeta, especially when it's fairly simple.
I don't want to order by just post_views, but by post_viewed, then (possible) by a custom field and then by post modified. Is that possible ?? Haven't looked to deep into the code.
Please store all post views in post_meta (where all post meta values should be stored).
When stored this way users can run our own queries and extend them with other taxonomies and meta queries (without writing extensive wpdb queries ourself).