fix: make topics reachable and stop the head fighting itself
Every topic archive rendered its character art gate against the design master, which package-theme.sh deliberately strips, so production showed an empty stage on all eight of them. Gate on the derivative the markup actually loads instead. Nothing linked to a topic archive: the only filter was a select inside a form, invisible to crawlers and to anyone not looking for it. The stream now also lists the non-empty topics as links, marking the current one. Empty topics stay out, because a dead archive is worse than no link. Rank Math already owns the document head, so the theme's own og: tags were a second, conflicting set and core's title tag was a literal duplicate. Both now yield when an SEO plugin is active. Category archives listed the same posts as their topic at a second indexable URL. They now redirect to the same-slug topic, or the Journal. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
28 files changed
+165
-25
No files matched your search
@@ -423,6 +423,36 @@ footer a {
|
||||
--chrnx-card-accent: #d36b3f;
|
||||
}
|
||||
|
||||
.chrnx-journal-stream__topics {
|
||||
margin-block-start: 1.5rem;
|
||||
}
|
||||
|
||||
.chrnx-journal-stream__topic {
|
||||
display: inline-block;
|
||||
padding: 0.4rem 0.9rem;
|
||||
border: 1px solid var(--chrnx-line);
|
||||
border-radius: 999px;
|
||||
color: var(--chrnx-muted);
|
||||
font-family: var(--wp--preset--font-family--metadata);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.12em;
|
||||
text-decoration: none;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.chrnx-journal-stream__topic:hover,
|
||||
.chrnx-journal-stream__topic:focus-visible {
|
||||
border-color: var(--chrnx-green);
|
||||
color: var(--chrnx-green);
|
||||
}
|
||||
|
||||
.chrnx-journal-stream__topic[aria-current="page"] {
|
||||
border-color: var(--chrnx-green);
|
||||
background: var(--chrnx-green);
|
||||
color: var(--chrnx-bg);
|
||||
}
|
||||
|
||||
.chrnx-journal-stream__filters {
|
||||
align-items: end;
|
||||
margin-block: 2rem;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/featured-stories",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Featured Stories",
|
||||
"category": "theme",
|
||||
"description": "A sticky-led selection of topic-diverse stories.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/footer-content",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "CHRNX Footer Content",
|
||||
"category": "theme",
|
||||
"description": "Display translated internal footer navigation and site credit.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/header-tools",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "CHRNX Header Tools",
|
||||
"category": "theme",
|
||||
"description": "Display translated primary navigation and progressive site search.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/journal-link",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Journal Link",
|
||||
"category": "theme",
|
||||
"description": "Display a translated portable link to the full Journal.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/journal-stream",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Journal Stream",
|
||||
"category": "theme",
|
||||
"description": "The filterable chronological journal.",
|
||||
|
||||
@@ -29,6 +29,37 @@ $chrnx_title = null !== $chrnx_pinned_term ? $chrnx_pinned_term->name : __( 'Jou
|
||||
?>
|
||||
<section <?php echo get_block_wrapper_attributes( array( 'class' => 'chrnx-journal-stream' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> aria-labelledby="<?php echo esc_attr( $chrnx_title_id ); ?>">
|
||||
<h<?php echo esc_attr( $chrnx_heading ); ?> id="<?php echo esc_attr( $chrnx_title_id ); ?>"><?php echo esc_html( $chrnx_title ); ?></h<?php echo esc_attr( $chrnx_heading ); ?>>
|
||||
<?php
|
||||
/*
|
||||
* The select below is invisible to crawlers and to anyone not hunting for it.
|
||||
* These are the same filters as real links, so topics have an entry point.
|
||||
* Empty topics stay hidden: a dead archive is worse than no link.
|
||||
*/
|
||||
$chrnx_topic_terms = get_terms(
|
||||
array(
|
||||
'taxonomy' => 'chrnx_topic',
|
||||
'hide_empty' => true,
|
||||
)
|
||||
);
|
||||
$chrnx_topic_terms = is_wp_error( $chrnx_topic_terms ) ? array() : $chrnx_topic_terms;
|
||||
?>
|
||||
<?php if ( count( $chrnx_topic_terms ) > 1 ) : ?>
|
||||
<nav class="chrnx-journal-stream__topics" aria-label="<?php echo esc_attr__( 'Topics', 'chrnx' ); ?>">
|
||||
<ul>
|
||||
<li>
|
||||
<a class="chrnx-journal-stream__topic" href="<?php echo esc_url( chrnx_get_full_journal_url() ); ?>"<?php echo '' === $chrnx_topic ? ' aria-current="page"' : ''; ?>><?php echo esc_html__( 'All', 'chrnx' ); ?></a>
|
||||
</li>
|
||||
<?php foreach ( $chrnx_topic_terms as $chrnx_term ) : ?>
|
||||
<?php $chrnx_term_link = get_term_link( $chrnx_term ); ?>
|
||||
<?php if ( ! is_wp_error( $chrnx_term_link ) ) : ?>
|
||||
<li>
|
||||
<a class="chrnx-journal-stream__topic" href="<?php echo esc_url( $chrnx_term_link ); ?>"<?php echo $chrnx_topic === $chrnx_term->slug ? ' aria-current="page"' : ''; ?>><?php echo esc_html( $chrnx_term->name ); ?></a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
<form class="chrnx-journal-stream__filters" method="get" action="<?php echo esc_url( $chrnx_form_url ); ?>">
|
||||
<?php if ( isset( $chrnx_fixed['taxonomy'] ) && 'chrnx_topic' === $chrnx_fixed['taxonomy'] ) : ?>
|
||||
<p class="chrnx-journal-stream__fixed-filter"><span><?php echo esc_html__( 'Topic', 'chrnx' ); ?></span> <strong><?php echo esc_html( $chrnx_fixed['label'] ); ?></strong></p>
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
.chrnx-journal-stream__topics ul {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.chrnx-journal-stream__filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/latest-podcast",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Latest Podcast",
|
||||
"category": "theme",
|
||||
"description": "A linked card for the latest podcast episode.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/mobile-menu-toggle",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "CHRNX Mobile Menu Toggle",
|
||||
"category": "theme",
|
||||
"description": "Progressively reveal the primary navigation on small screens.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/podcast-meta",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Podcast Metadata",
|
||||
"category": "theme",
|
||||
"description": "Safe episode details for the current post.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/reading-time",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Reading Time",
|
||||
"category": "theme",
|
||||
"description": "Display a localized estimate based on the current post content.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/related-posts",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Related Posts",
|
||||
"category": "theme",
|
||||
"description": "Related stories selected by topic, tags, and recency.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/release-detail",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Release Detail",
|
||||
"category": "theme",
|
||||
"description": "Album cover, listening links, and the ordered tracklist.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/release-list",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Release List",
|
||||
"category": "theme",
|
||||
"description": "The No Names releases, each linking to its album page.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/selected-work",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Selected Work",
|
||||
"category": "theme",
|
||||
"description": "Hand-picked projects first, then the most recent ones.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/show-links",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Show Links",
|
||||
"category": "theme",
|
||||
"description": "Where a podcast show can be listened to, rendered only when a URL exists.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/site-brand",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "CHRNX Site Brand",
|
||||
"category": "theme",
|
||||
"description": "Display the local CHRNX wordmark linked to the site home.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/subscribe-cta",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Subscribe CTA",
|
||||
"category": "theme",
|
||||
"description": "A call to action linked to the configured subscribe page.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/subscribe-form",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Subscribe Form",
|
||||
"category": "theme",
|
||||
"description": "The email subscription form, rendered only when a provider endpoint is configured.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/theme-toggle",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Theme Toggle",
|
||||
"category": "theme",
|
||||
"description": "Choose a light, dark, or system color theme.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/topic-hero",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Topic Hero",
|
||||
"category": "theme",
|
||||
"description": "A fixed-art hero for an editorial topic.",
|
||||
|
||||
@@ -22,7 +22,14 @@ $chrnx_art_topic = 'chrnx_show' === $chrnx_taxonomy ? 'podcasts' : $chrnx_topic;
|
||||
$chrnx_asset = chrnx_get_topic_art_asset( $chrnx_art_topic );
|
||||
$chrnx_size = chrnx_get_topic_art_dimensions( $chrnx_art_topic );
|
||||
$chrnx_has_art = '' !== $chrnx_asset && 2 === count( $chrnx_size );
|
||||
$chrnx_has_image = $chrnx_has_art && is_readable( get_theme_file_path( $chrnx_asset ) );
|
||||
/*
|
||||
* The packaged theme ships only assets/images/generated, so the design master
|
||||
* is absent in production and gating on it hid the art on every topic archive.
|
||||
* Check the derivative the markup actually loads.
|
||||
*/
|
||||
$chrnx_has_image = $chrnx_has_art && is_readable(
|
||||
get_theme_file_path( 'assets/images/generated/' . pathinfo( $chrnx_asset, PATHINFO_FILENAME ) . '-768.webp' )
|
||||
);
|
||||
$chrnx_heading = chrnx_get_heading_level( $attributes['headingLevel'] ?? 2, 2 );
|
||||
$chrnx_term = $chrnx_queried instanceof WP_Term && $chrnx_queried->slug === $chrnx_topic ? $chrnx_queried : get_term_by( 'slug', $chrnx_topic, 'chrnx_topic' );
|
||||
$chrnx_label = $chrnx_term instanceof WP_Term ? $chrnx_term->name : ucwords( str_replace( '-', ' ', $chrnx_topic ) );
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/track-meta",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"title": "Track Meta",
|
||||
"category": "theme",
|
||||
"description": "Player, listening links, and album for one song.",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
define( 'CHRNX_VERSION', '0.3.0' );
|
||||
define( 'CHRNX_VERSION', '0.4.0' );
|
||||
|
||||
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
|
||||
foreach ( array( 'setup', 'assets', 'taxonomies', 'editor', 'podcast-meta', 'project-meta', 'release-meta', 'show-meta', 'track-meta', 'settings', 'queries', 'media', 'blocks', 'theme-preference' ) as $module ) {
|
||||
|
||||
+29
-2
@@ -33,11 +33,17 @@ add_action( 'after_setup_theme', 'chrnx_setup' );
|
||||
add_filter( 'comments_open', '__return_false' );
|
||||
|
||||
/**
|
||||
* Print Open Graph and Twitter card tags for the current request.
|
||||
* Print Open Graph and Twitter card tags only when nothing else does.
|
||||
*
|
||||
* ponytail: hand-rolled because the theme needs four tags, not an SEO plugin.
|
||||
* ponytail: an installed SEO plugin already emits these per post, with the
|
||||
* right title and image. Two sets of og: tags let crawlers pick the wrong one,
|
||||
* so the theme yields and only covers the no-plugin case.
|
||||
*/
|
||||
function chrnx_print_social_meta() {
|
||||
if ( chrnx_has_seo_plugin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( is_singular() ) {
|
||||
$title = get_the_title();
|
||||
$url = get_permalink();
|
||||
@@ -79,3 +85,24 @@ function chrnx_print_social_meta() {
|
||||
echo '<meta name="twitter:card" content="summary_large_image" />' . "\n";
|
||||
}
|
||||
add_action( 'wp_head', 'chrnx_print_social_meta' );
|
||||
|
||||
/**
|
||||
* Report whether an SEO plugin owns the document head.
|
||||
*
|
||||
* @return bool True when a known SEO plugin is active.
|
||||
*/
|
||||
function chrnx_has_seo_plugin(): bool {
|
||||
return defined( 'RANK_MATH_VERSION' ) || defined( 'WPSEO_VERSION' ) || defined( 'SEOPRESS_VERSION' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop core's title tag when an SEO plugin prints its own.
|
||||
*
|
||||
* Both were rendering, so every page shipped two <title> elements.
|
||||
*/
|
||||
function chrnx_remove_duplicate_title_tag() {
|
||||
if ( chrnx_has_seo_plugin() ) {
|
||||
remove_action( 'wp_head', '_wp_render_title_tag', 1 );
|
||||
}
|
||||
}
|
||||
add_action( 'wp_head', 'chrnx_remove_duplicate_title_tag', 0 );
|
||||
@@ -123,6 +123,42 @@ function chrnx_seed_editorial_terms() {
|
||||
}
|
||||
add_action( 'after_switch_theme', 'chrnx_seed_editorial_terms' );
|
||||
|
||||
/**
|
||||
* Retire the legacy category archives.
|
||||
*
|
||||
* chrnx_topic is the editorial taxonomy. Category archives listed the same
|
||||
* posts at a second indexable URL, so both competed for the same queries.
|
||||
* A same-slug topic keeps that equity; everything else folds into the Journal.
|
||||
*
|
||||
* ponytail: matching by slug instead of a hand-kept category-to-topic map.
|
||||
*/
|
||||
function chrnx_redirect_legacy_category_archives() {
|
||||
if ( ! is_category() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$category = get_queried_object();
|
||||
$target = '';
|
||||
if ( $category instanceof WP_Term ) {
|
||||
$topic = get_term_by( 'slug', $category->slug, 'chrnx_topic' );
|
||||
if ( $topic instanceof WP_Term && $topic->count > 0 ) {
|
||||
$link = get_term_link( $topic );
|
||||
$target = is_wp_error( $link ) ? '' : $link;
|
||||
}
|
||||
}
|
||||
|
||||
if ( '' === $target ) {
|
||||
$target = chrnx_get_full_journal_url();
|
||||
}
|
||||
if ( '' === $target ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_safe_redirect( $target, 301 );
|
||||
exit;
|
||||
}
|
||||
add_action( 'template_redirect', 'chrnx_redirect_legacy_category_archives' );
|
||||
|
||||
/**
|
||||
* Return the current user's editorial notice transient key.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user