Last active
March 16, 2019 01:06
-
-
Save blogjunkie/782f3ec48b41c4d7dce1 to your computer and use it in GitHub Desktop.
Custom page titles for co-authors with WordPress SEO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom page titles for Guest Authors with WordPress SEO | |
* Returns "[author name]'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 . ''s articles on ' . get_bloginfo('name'); | |
} | |
return $title; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great fix! Do you mind if I package this up as tiny patch plugin?