Skip Navigation

[Resolved] Count post views and order by that count on a View

This thread is resolved. Here is a description of the problem and solution.

Problem

How can I create a view that displays the most viewed post on top, the less seen on the bottom of the list generated?

Solution

The sort, ordering or even querying by a "post-view" count would not be the problem in Toolset, the issue is more that we would need to add a tracking system to somehow count views of Posts.

If you find a Plugin that adds this in form of PostMeta, then you can use this information to order or query a View output.

An example that should work:
https://de.wordpress.org/plugins/post-views-counter/

Or, even nicer, a custom logic code:
http://wpsnipp.com/index.php/cache/track-post-views-without-a-plugin-using-post-meta/

This last code uses post meta, which is perfect for the case here.

However be careful storing such data and always check if this complies with GDPR laws.

This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 3 replies, has 3 voices.

Last updated by Beda 6 years, 4 months ago.

Assisted by: Beda.

Author
Posts
#626685

Being able to use views to sort posts by most popular would be a cool feature

I know there are a few plugins out there that do that - but one of the things I like about Toolset is that you don't need to install a lot of additional plugins

Anyway just a thought - its a requirement I keep coming up against so thought I would mention it.

#626894

The sort, ordering or even querying by a views' count should not be the problem, the issue is more that we would need to add a tracking system to somehow count views.

That is not only out of the scope of the Toolset project, but it may also conflict with future laws like GDPR.
If we were to add such features, we would require adding as well several control mechanisms for the user to approve, delete or reject sharing that data with you.

I do file every request, and neither mine nor the Developers words are the last.
We count votes, we analyse the doability and necessity, and more factors.
According to that, we decide whether to add or not something.

For now, the solution would be to use a Plugin to count the Views, and then display or order by that with Toolset Views.
It needs to be a plugin that stores those view counts in a custom post field.
Then you can use it with Toolset.

An example that should work:
hidden link

Or, even nicer, a custom logic code:
hidden link

This last code uses post meta, which is perfect for the case here.

#923810

Hello, i registered shortcode but how i can to insert in my views? I use second link and
add_shortcode( 'postallviews', 'getPostViews');
<code from second link>
in views
<span class="read">[postallviews]</span>
not work

#924950

@rostislava if this is related to Toolset, please open your own, new Ticket about the specific issue.

Then we can try to help.

Thank you!