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
+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