KD Tree Service Core
Production WordPress plugin powering KD Tree Service functionality: custom post types, taxonomy, native meta fields (no ACF), rewrite-based virtual pages, template loader, and lightweight UI helpers.
by Helani Thejangi · github.com/thejangi/kd-tree-service-core
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/thejangi/kd-tree-service-core/archive/refs/heads/main.zipKD Tree Service Core (Plugin)
A custom WordPress plugin powering KD Tree Service website functionality.
What this plugin provides
- Registers content model (NO ACF):
- CPT:
service-location - CPT:
service(recommended) - Taxonomy:
state(for locations)
- CPT:
- Registers custom fields as post meta (location contact data, coordinates, etc.)
- Provides editor UI (Gutenberg sidebar panels) for managing location meta
- URL routing (must keep):
- Location CPT single:
/service-location/{location-slug}/ - Virtual location-service pages:
/{location-slug}/{service-slug}/
- Location CPT single:
- Template loader for virtual routes (
/{location}/{service}/) - ZIP code detector logic (header + footer UI support)
- Data provider for header Locations mega menu (State → Cities)
- Map/state view support for Locations hub (performance-first)
Requirements
- WordPress 6.4+ (recommended)
- PHP 8.0+
- Works best with the kd-tree-service Block Theme repo
Installation
- Copy the folder into:
wp-content/plugins/kd-tree-service-core/ - Activate in Plugins → Installed Plugins
- Visit Settings → Permalinks and click Save Changes (flush rewrite rules)
URL Rules (must keep)
Location page
/service-location/{location-slug}/
Location-service virtual page
/{location-slug}/{service-slug}/
This plugin resolves the virtual route using rewrite rules + a template loader.
Main modules (includes/)
class-cpt.php– register CPTsclass-taxonomies.php– registerstatetaxonomyclass-meta.php– register post meta (no ACF) + REST supportclass-rewrites.php– rewrite rules + query vars + route validationclass-template-loader.php– loads templates for virtual routesclass-zip-detector.php– ZIP detection logic (cookie/localStorage + endpoint if needed)class-mega-menu.php– returns State → Cities data for mega menu block
Templates
templates/virtual-location-service.php
Used when rendering/{location-slug}/{service-slug}/
Performance principles
- No PHP sessions
- Load scripts/styles only when needed (block/page scoped)
- Map assets load only on pages that include map UI
SEO (Rank Math)
Rank Math is used for editor scoring.
Later, this plugin can hook into Rank Math filters to set meta/schema for virtual routes.
Development notes
- Follow WordPress Coding Standards
- Use secure escaping/sanitization for meta fields and outputs
- Avoid output buffering to rewrite HTML
- Prefer dynamic blocks or structured template rendering
Versioning & Updates
- Update plugin header version in
kd-tree-service-core.php - Tag releases in GitHub (e.g.
v1.0.1) - Use Git Updater (or similar) on the site to pull updates via WP dashboard
License
Add the chosen license here (e.g. GPL-2.0-or-later).