Voxel Counter of Post Relations

  • Member Access
  • Count the number of post type relations that are associated with the related posts by using a wordpress simple function.

🔄 Voxel Resources & Relations – Auto Count Setup Guide 📊

Syncing live relation counts between post types like Resources, Support Tickets, Feature Requests, and Changelogs.

Let’s walk through everything step-by-step — from manual setup to automatic meta syncing. 🔧


📌 Step 1: Setup Post Relations Between Post Types

In this system, each post type is connected to others via post relations with shared relation keys. Here’s how to set it up:

📁 In the Resources post type:

Create 3 post relations, one for each connected post type:

➕ Add:

  • Name: Related to Support Ticket

  • Type: Belongs to many

  • Related to: Support Tickets

  • Relation key: support-tickets

  • Name: Related to Feature Request

  • Type: Belongs to many

  • Related to: Feature Requests

  • Relation key: feature-requests

  • Name: Related to Changelog

  • Type: Belongs to many

  • Related to: Changelogs

  • Relation key: changelogs


🧾 In the Support Tickets, Feature Requests, and Changelogs post types:

Create a mirrored relation that points back to Resources:

➕ Add:

  • Name: Related to Resource

  • Type: Has one

  • Related to: Resources

  • Relation key: same as above (e.g. support-tickets)

✅ Repeat this setup for each relevant post type to ensure they all sync correctly.


🧮 Step 2: Create Meta Fields to Store the Counts

We’re going to store the number of related posts inside a custom field for display, filters, or logic.

In Resources:

➕ Add a Number field:

  • Label: Total Support Tickets

  • Field Key: total_support_tickets

  • Min: 0, Max: 99999

(Repeat for total_feature_requests, total_changelogs)


In Support Tickets:

➕ Add a Number field:

  • Label: Total Resources

  • Field Key: total_resources

  • Min: 0, Max: 99999

(Repeat similarly for other post types as needed)


⚙️ Step 3: Auto-Syncing Logic in Code

Drop the following code into a plugin or your theme’s functions.php.
This will auto-calculate and update the counts in your custom meta fields every time a post is:

  • Created

  • Updated

  • Published/unpublished

  • Modified via Voxel’s interface

What the function does:

  • 🔍 Looks in the voxel_relations table

  • 📊 Counts how many published posts are related

  • 💾 Saves the number in your custom field (update_post_meta)

  • 🔁 Syncs both the post and all its related posts


🧩 Step 4: Display the Counts Anywhere

Now that you have custom fields like total_support_tickets or total_resources, you can use them anywhere in Voxel:

🖼️ In Elementor (or the template builder):

  • Drag in a Number field widget

  • Choose the correct field (e.g. total_resources)

  • Style it however you like (icons, labels, etc.)


✅ You’re Done!

Now your Voxel site automatically:

  • Keeps track of the post relationships

  • Updates total counts whenever things change

  • Stores those counts for easy use in layouts, filters, or conditional logic

This code goes in your Code Snippets Manager or functions.php of your Child theme

  • UI/UX Designer & Wordpress Developer
  • Other Resources

Live check for new Notifications and Messages in Voxel. Updates live the page title (X), favicon and the bell/inbox icons.

Looking to drop custom scripts without editing your theme’s files? 📌 WPCode Lite lets you paste any snippet—HTML/JS/CSS/PHP—directly into your site’s global header, body, or footer, all from one streamlined settings page.

  • Third-party
  • 1

Allow visitors to sort your posts by number of views, here’s a simple way to make it happen without any complex plugin.