How to Make “Post Views” a Sortable Field in Voxel
If you want to allow visitors to sort your posts by number of views, here’s a simple way to make it happen without any complex plugin.
✅ First, create a number field for your post type fields:
-
Field name: Post Views
-
Field key:
post_views
✅ Next, go to Filters → Search order inside Voxel and add a Custom Order:
-
Type: Number Field
-
Field: Post Views
✅ Now for the magic: let’s automatically sync the real view counts into that post_views
field every few minutes.
You just need to add this small function inside your Child Theme’s functions.php
or with a plugin like WPCode to insert it as a Snippet.
Voxel → Post Views synchroniser
What does this function do?
- It reads the real number of views from Voxel’s internal voxel:view_counts.
- It writes the total view count into your post_views number field.
- It automatically updates every 10 minutes (no need to manually refresh or re‑save posts).
*Make sure to change “component” with your own post type key name*
No results available
ResetNo results available
Reset