From d7dbe7fee362d587dfc334135d9581b6216a4295 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 23 Nov 2025 04:13:56 +0000
Subject: [PATCH] =Timeline block, and feed block updated. DataStore.js refactored to not block rendering

---
 inc/registry/TaxonomyRegistrar.php |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/inc/registry/TaxonomyRegistrar.php b/inc/registry/TaxonomyRegistrar.php
index e31fc5a..489dd12 100644
--- a/inc/registry/TaxonomyRegistrar.php
+++ b/inc/registry/TaxonomyRegistrar.php
@@ -55,12 +55,32 @@
 		$post_types = array_map(fn($type) => BASE . $type, $this->config['for_content'] ?? []);
 		register_taxonomy($this->taxonomy, $post_types, $args);
 
+		$this->maybeAddRewriteRule($args['rewrite']);
 		if (!empty($this->fields)) {
 			$meta_registry = new MetaRegistry($this->fields, $this->slug, 'term');
 			$meta_registry->registerMetaFields();
 		}
 	}
 
+	/**
+	 * Add custom rewrite rule for hierarchical taxonomy slugs (e.g., post-type/by/taxonomy-slug)
+	 */
+	protected function maybeAddRewriteRule(array $rewrite_config): void
+	{
+		$slug = $rewrite_config['slug'] ?? $this->slug;
+
+		// Only add custom rule if slug contains slashes (hierarchical path)
+		if (!str_contains($slug, '/')) {
+			return;
+		}
+
+		add_rewrite_rule(
+			"^{$slug}/([^/]+)/?$",
+			'index.php?' . $this->taxonomy . '=$matches[1]',
+			'top'
+		);
+	}
+
     private function buildLabels(string $singular, string $plural): array
     {
         return [

--
Gitblit v1.10.0