How to Sort Posts by View Count on Elementor

How to Sort Posts by View Count on Elementor

If you’re building a WordPress blog or magazine, you might be wondering how to sort posts by view count on Elementor. In this step-by-step tutorial, I’ll show you exactly how you can sort blog posts by view count on Elementor and how to show the view count on your posts directly.

1. Install WP-PostViews

The first step to sort posts by view count on Elementor is to install WP-PostViews on your WordPress website. It’s a simple plugin that keeps track of the number of views for each blog post on your website.

Here’s how to install WP-PostViews on your website:

  1. Download the plugin here.
  2. Once the plugin is downloaded on your computer, navigate to Plugins > Add New on WordPress.
  3. Then, click on “Upload Plugin” at the top of the screen and select the file you just downloaded.
  4. After that, you can click on “Install Now” to install the plugin on WordPress.
  5. Finally, you can click on “Activate” to activate the plugin on your website.

2. Set up WP-PostViews

Once WP-PostViews is installed on your WordPress website, you’ll need to set up the settings of the plugin.

Here are all the settings of WP-PostViews and what I recommend using:

  • Count Views From: Here you select where to count views from, I’d recommend using “Guests Only” to make sure you don’t create fake views when viewing your own website.
  • Exclude Bot Views: Here you can select whether or not you’d like to exclude bot views from your view count. Usually, I’d recommend enabling it because it’s not an accurate representation of how many people read it.
  • Use AJAX To Update Views: Usually, I’d recommend using AJAX to update views but in rare cases, if it doesn’t work, you can disable it, which might fix the issue.

3. Test the view count

Now that WP-PostViews is installed and working on your website, it’s time to test it to see if it works. If you navigate to your posts on WordPress, you should see a new column that says “Views”.

You can just open one of your posts in a new private window and see if the view count goes up. If it works you can go to the next step, but if it doesn’t work you should try disabling “AJAX To Update Views” in the settings.

4. Install Advanced Post Queries

Once WP-PostViews is installed, set up, and fully working, it’s time to install Advanced Post Queries.

Advanced Post Queries is a simple Elementor extension that lets you dynamically query your posts and portfolio widget results without custom query IDs. Basically, the plugin is what lets Elementor communicate with the view counts.

Here’s how to install Advanced Post Queries on your website:

  1. Download the plugin here.
  2. Once the plugin is downloaded on your computer, navigate to Plugins > Add New on WordPress.
  3. Then, click on “Upload Plugin” at the top of the screen and select the file you just downloaded.
  4. After that, you can click on “Install Now” to install the plugin on WordPress.
  5. Finally, you can click on “Activate” to activate the plugin on your website.

5. Sort by view count on Elementor

The last step to sort posts by view count on Elementor is to add an advanced query option to your post element.

Here’s exactly how you can do it:

  1. Edit the page where you want to sort posts by view count with Elementor.
  2. Select the “Posts” element by clicking on it
  3. In the left panel, open the “Query” options
  4. Then, you should be able to select “Advanced OrderBy Options” under “Advanced Query Options”
  5. After that, you can select “Dynamic OrderBy Field” under “Dynamic OrderBy Options”
  6. Finally, you need to write “views” under “Dynamic OrderBy Field”

Now if you update the page and look at it on your website, all your posts should be sorted by the most popular!

6. Add the view count to your posts (optional)

In some cases, you might want to show the view count directly on the posts and here’s how:

  1. Edit your “Single Post” template using Elementor
  2. Select (or add) the element called “MetaData” that shows the date, author, etc…
  3. Add a new item to the list
  4. Select “Custom” as the type of the item
  5. Click on the “Dynamic Tags” under the “Custom” field
  6. Then click on “Post Custom Field”
  7. Finally, select “views” as your key

However, that’s only going to show the view count on your article, if you want it to say “x views” you have to add the word “views” after the count. To do that, you simply have to open the advanced settings and add ” Views” after the view count.

Conclusion

That’s it! You should now be able to sort your posts by view count and show the view counts on each post.

If you want to learn more about Elementor or need more help building your Elementor website, I’d recommend checking out all our free Elementor tutorials here.

Total
0
Shares
3 comments
  1. This is great, but I am not able to get it to work on an archive category page. I am looking to sort by views within a category. When using the source as a post, it works and sorts by view count, but then I lose the category filter.

    An example is https://kinni.co/category/connecting/ where the post “How to connect to your treadmill” should be sorted to the first post in the list as it has the most views.

    Element used: Posts
    Query:
    Source = Current Query

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
What are the limitations of using WordPress?

What are the Limitations of Using WordPress?

Next Post
How Much Does it Cost to Build a WordPress Website

How Much Does it Cost to Build a WordPress Website?

Related Posts