Skip to content

Instantly share code, notes, and snippets.

@blogjunkie
Last active March 16, 2019 01:06
Show Gist options
  • Save blogjunkie/782f3ec48b41c4d7dce1 to your computer and use it in GitHub Desktop.
Save blogjunkie/782f3ec48b41c4d7dce1 to your computer and use it in GitHub Desktop.
Custom page titles for co-authors with WordPress SEO
<?php
/**
* Custom page titles for Guest Authors with WordPress SEO
* Returns "[author name]&#39;s articles on [site name]"
*
*/
add_filter('wpseo_title', 'my_co_author_wseo_title');
function my_co_author_wseo_title( $title ) {
// Only filter title output for author pages
if ( is_author() && function_exists( 'get_coauthors' ) ) {
$qo = get_queried_object();
$author_name = $qo->display_name;
return $author_name . '&#39;s articles on ' . get_bloginfo('name');
}
return $title;
}
@edmyersjr
Copy link

edmyersjr commented Mar 15, 2019

Great fix! Do you mind if I package this up as tiny patch plugin?

@blogjunkie
Copy link
Author

Sure, go ahead @edmyersjr! Glad it’s helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment