This commit is contained in:
IGNY8 VPS (Salman)
2026-01-10 07:28:11 +00:00
parent ceee9ba34d
commit af95454049
5 changed files with 88 additions and 32 deletions

View File

@@ -52,14 +52,16 @@ if (!defined('ABSPATH')) {
<!-- Topic (Cluster Name) -->
<?php if ($cluster_name):
// Try to find a tag or category matching the cluster name for linking
$cluster_link = '';
// Create search URL for cluster name as fallback
$cluster_link = add_query_arg('s', urlencode($cluster_name), home_url('/'));
// Try to find a tag or category matching the cluster name
$cluster_tag = get_term_by('name', $cluster_name, 'post_tag');
if ($cluster_tag) {
if ($cluster_tag && !is_wp_error($cluster_tag)) {
$cluster_link = get_term_link($cluster_tag);
} else {
$cluster_cat = get_term_by('name', $cluster_name, 'category');
if ($cluster_cat) {
if ($cluster_cat && !is_wp_error($cluster_cat)) {
$cluster_link = get_term_link($cluster_cat);
}
}
@@ -69,15 +71,11 @@ if (!defined('ABSPATH')) {
<path fill-rule="evenodd" d="M5.05 4.05a7 7 0 119.9 9.9L10 18.9l-4.95-4.95a7 7 0 010-9.9zM10 11a2 2 0 100-4 2 2 0 000 4z"/>
</svg>
<span class="igny8-meta-label">Topic:</span>
<?php if ($cluster_link && !is_wp_error($cluster_link)): ?>
<a href="<?php echo esc_url($cluster_link); ?>" class="igny8-meta-value igny8-clickable-link"><?php echo esc_html($cluster_name); ?></a>
<?php else: ?>
<span class="igny8-meta-value"><?php echo esc_html($cluster_name); ?></span>
<?php endif; ?>
<a href="<?php echo esc_url($cluster_link); ?>" class="igny8-meta-value igny8-clickable-link"><?php echo esc_html($cluster_name); ?></a>
</div>
<?php endif; ?>
<!-- Categories (with hierarchy) -->
<!-- Categories (each level separately clickable) -->
<?php if ($categories && !is_wp_error($categories)): ?>
<div class="igny8-meta-item">
<svg class="igny8-icon" viewBox="0 0 20 20" fill="currentColor">
@@ -86,17 +84,23 @@ if (!defined('ABSPATH')) {
<span class="igny8-meta-label">Categories:</span>
<div class="igny8-meta-badges">
<?php foreach ($categories as $cat):
// Build full hierarchy path
// Build full hierarchy path with each level clickable
$hierarchy = [];
$current_cat = $cat;
while ($current_cat) {
array_unshift($hierarchy, $current_cat);
$current_cat = $current_cat->parent ? get_category($current_cat->parent) : null;
}
// Output each category in hierarchy as separate clickable link
$hierarchy_links = [];
foreach ($hierarchy as $h_cat) {
$hierarchy_links[] = '<a href="' . esc_url(get_category_link($h_cat->term_id)) . '" class="igny8-category-link">' . esc_html($h_cat->name) . '</a>';
}
?>
<a href="<?php echo esc_url(get_category_link($cat->term_id)); ?>" class="igny8-category-badge igny8-clickable-badge">
<?php echo esc_html(implode(' ', array_map(function($c) { return $c->name; }, $hierarchy))); ?>
</a>
<span class="igny8-category-badge">
<?php echo implode(' <span class="igny8-cat-separator"></span> ', $hierarchy_links); ?>
</span>
<?php endforeach; ?>
</div>
</div>