dfactoryplugins / post-views-counter

Post Views Counter
56 stars 20 forks source link

Feature request: Store post view in post_meta instead of own table #14

Closed Beee4life closed 6 years ago

Beee4life commented 7 years ago

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).

bartoszarendt commented 7 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

Beee4life commented 7 years ago

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.