Skip to content

Instantly share code, notes, and snippets.

@bekarice
Created April 19, 2018 19:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bekarice/3b10ff466c353d0d8eb0bc8bc1e22c5d to your computer and use it in GitHub Desktop.
Save bekarice/3b10ff466c353d0d8eb0bc8bc1e22c5d to your computer and use it in GitHub Desktop.
Forces Yoast to use the display name directly for the queried object so the proper coauthor name is used as the page title.
<?php // only copy if needed!
/**
* Fixes page titles for co-author archives.
*
* @param string[] $replacement Yoast title settings replacement data
* @return string[] updated data
*/
function br_fix_author_archive_title( $replacement ) {
if ( is_author() && isset( $replacement['%%name%%'] ) ) {
$replacement['%%name%%'] = get_queried_object()->display_name;
}
return $replacement;
}
add_filter( 'wpseo_replacements', 'br_fix_author_archive_title' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment